Solved Execute event if invClick getCurrentItem matches defined item

Discussion in 'Plugin Development' started by Froshin, May 27, 2013.

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

    Froshin

    Code:
      @EventHandler
        private void onPlayerPickupItem(InventoryClickEvent e){
         
         
            if (e.getInventory().getHolder() instanceof Player){
         
             
            Player p = (Player) e.getInventory().getHolder();
            p.sendMessage("You're defined!");
         
            ItemStack AssItem = new ItemStack(Material.FEATHER.getId(), 1);
                ItemMeta AssMeta = AssItem.getItemMeta();
           
     
                AssMeta.setDisplayName("Assasin");
                AssItem.setItemMeta(AssMeta);
     
            if (e.getCurrentItem().getTypeId() == Material.FEATHER.getId()){
             
                Server serv = Bukkit.getServer();
                serv.broadcastMessage("Well, it worked! But who the fuck are you?");
                p.sendMessage("Check! 1");
                if (e.getCurrentItem() == AssMeta){
                 
                    p.sendMessage("FINAL CHECK YAY IT WORKED WOOHOO!!!");
                 
                }
             
             
             
            }
         
         
            }
        }


    It returns all the messages except the final check.

    The item is obtainable through opening a shop, the owner of the shop is set to the player itself. Then, AssItem is defined exactly the way it is in this script, so the obtained item should be identical. Yet it won't work.

    Why could this be? Is the ItemMeta tied to the inventory owner or something?

    Thanks in advance!
     
  2. Offline

    MCPvPCraft

    Try:
    Code:java
    1.  
    2. if (e.getCurrentItem().equals(AssMeta)){
    3. }
    4.  
     
    Froshin likes this.
  3. Offline

    Froshin

Thread Status:
Not open for further replies.

Share This Page