Solved LEFT_CLICK_BLOCK and RIGHT_CLICK_BLOCK

Discussion in 'Plugin Development' started by Jamesterjim, Dec 30, 2012.

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

    Jamesterjim

    Hello everyone.

    I have a plugin, when you take items out of chests it will keep the item there and then give it you in your inventory.

    LEFT_CLICK_BLOCK and RIGHT CLICK BLOCK are red underlined saying "Cannot be resolved or is not a field"

    Is there a better way of doing this?

    Thankyou, James.

    Here is my code.

    Code:
        @EventHandler()
        public void onChestOpen(PlayerInteractEvent event) {
            Player p = (Player) event.getPlayer();
            Block block = event.getClickedBlock();
            if(event.getAction().equals(Action.LEFT_CLICK_BLOCK) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK) && block != null);
            {
                if(block.getState() instanceof Chest || block.getState() instanceof DoubleChest)
                {
                    Chest chest = ((Chest) block.getState());
                    ItemStack[] items = chest.getInventory().getContents();
                    p.getInventory().addItem(items);
                    p.updateInventory();
                    }}
                 
                }
     
  2. Offline

    fireblast709

    Use the correct import for that: org.bukkit.event.block.Action
     
  3. Offline

    Jamesterjim

    I imorted the wrong Action.

    I needed import org.bukkit.event.block.Action;

    Oh Thankyou fireblast, did not see that :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
Thread Status:
Not open for further replies.

Share This Page