Solved Interact event not wokring.

Discussion in 'Plugin Development' started by Hellborn5456, Apr 29, 2015.

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

    Hellborn5456

    Code:
        @EventHandler
        public void playerInteract(PlayerInteractEvent event){
            ItemStack item1 = new ItemStack(Material.COMPASS);
            ItemMeta meta = item1.getItemMeta();
            meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Main.getInstance().getConfig().getString("pvp.compass")));
            item1.setItemMeta(meta);
                Player player = event.getPlayer();
                if(player.getItemInHand().getType().equals(item1.getItemMeta())){
                    if(event.getAction() == (Action.RIGHT_CLICK_AIR) && event.getAction() == (Action.RIGHT_CLICK_BLOCK)){
                    Main.getInstance().getServer().dispatchCommand(Bukkit.getConsoleSender(), "/battle");
                        player.sendMessage("hey");
                }
            }
        }
    Yes i register events.

    Nvm i got it.

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Apr 29, 2015
  2. How can a Material be equal to ItemMeta??
    Use
    Code:
    if (player.getItemInHand().equals(item1)) {
    and
    The action can't be two things at once. Use the || operator instead.
    and
    I think this will dispatch the command //battle
    and
    Why not just
    Code:
    Bukkit.dispatchCommand
     
Thread Status:
Not open for further replies.

Share This Page