How do I make it so when a player types a command and looks at an cauldron......

Discussion in 'Plugin Development' started by Primescore, Jun 15, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Primescore

    My plugin is a trash plugin and I want to make it so you type a command and it saves the cauldron as a trash can.

    What is the code(s) for; when a player types /trash create and is looking at a cauldron, it saves the cauldron as a trash can and I will put my code for when a player hits the cauldron the item in their hand "goes away".
     
  2. Offline

    XbannisherX

    get the Event
    this will remove the item from there hand when they left click it
    its up to you to fill in the rest :)

    Code:
     @EventHandler
    public void OnPlayerClickEvent(PlayerInteractEvent event) {
        Material type = event.getClickedBlock().getType();
        Action ac = event.getAction();
        Player p = event.getPlayer();
        if(type == Material.CAULDRON)&&
            (ac == ac.LEFT_CLICK_BLOCK){
            ItemStack item =  p.getItemInHand();
            item.setAmount(0);
        }
     
Thread Status:
Not open for further replies.

Share This Page