Inventory Click Event doesn't Fire on PlayerInventory Click

Discussion in 'Spigot Plugin Development' started by Bladian, Jun 15, 2016.

  1. Hello!

    As you can see from the title I'm on a stump.

    Here's the code I've tried.

    Code (Text):
      Player p = (Player) e.getWhoClicked();
            ItemStack itemStack = e.getCurrentItem();
            Bukkit.broadcastMessage(e.getInventory().getType().toString());
            if(e.getInventory().getType() == InventoryType.PLAYER)
            {
                Bukkit.broadcastMessage("kkffj");
            }
            if(e.getInventory().equals(p.getInventory()))
            {
                Bukkit.broadcastMessage("kys");
                if (objects.isEditingKit(p))
                {
                    Bukkit.broadcastMessage("true");
                    if (e.getSlotType() == InventoryType.SlotType.ARMOR)
                    {
                        Bukkit.broadcastMessage("true1");
                        e.setCancelled(true);
                        return;
                    }
                    Bukkit.broadcastMessage("true4");
                    e.setCancelled(false);
                    return;
                }
            }
            Bukkit.broadcastMessage("IT WORKS EY DOD");
    Only the last message executes.

    Thanks for any help!
     
  2. so basically, this means if the inventory is their own inventory.
     
  3. Try to check inventory names, not their objects
     
  4. The problem is it literally doesn't see the Player Inventory as an inventory. I'm running out of ideas to why.


     
  5. Update: It now returns the crafting inventory when I click the player inventory. Again no clue why.
     
  6. Sorry want to update again. I cannot move any of my items in my inventory, there is no logical reason for why this is happening. But it just keeps cancelling.

    Thank you for your help.