Solved InventoryClickEvent not firing

Discussion in 'Plugin Development' started by cfil360, Jun 16, 2014.

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

    cfil360

    For some reason my inventory click event isn't firing in a custom inventory. I know the listener is registered because i receive the debug message with other inventories. It's kinda hard to explain but i have 2 custom inventories. One of them is working with the listener and the other isn't. There should be a broadcasted "click" everytime but it doesn't happen with the second inventory.

    Code:java
    1. @EventHandler
    2. public void onInventoryClick(InventoryClickEvent e) {
    3. Bukkit.broadcastMessage("click");
    4. if(e.getInventory().getName().equalsIgnoreCase(InventoryHandler.getShopInventory().getName())) {
    5. if(e.getCurrentItem() == null || e.getCurrentItem().getType() == Material.AIR) return; //return if the item is null or air
    6. //transfer to verification inventory
    7. e.getWhoClicked().closeInventory();
    8. loadVerificationInventory(e.getWhoClicked(), e.getCurrentItem());
    9. e.setCurrentItem(new ItemStack(Material.AIR));
    10. //return;
    11. }
    12. if(e.getInventory().getName().equalsIgnoreCase(InventoryHandler.getVerificationInventory().getName())) {
    13. Bukkit.broadcastMessage("inv");
    14. if(!InventoryHandler.isStoreItem(e.getCurrentItem())) return; //return if the item isn't a store item
    15. Bukkit.broadcastMessage("sotre item");
    16. //check location of item
    17. if(e.getSlot() == 0 || e.getSlot() == 1 || e.getSlot() == 9 || e.getSlot() == 10 || e.getSlot() == 18 || e.getSlot() == 19 || e.getSlot() == 27 || e.getSlot() == 28 || e.getSlot() == 36 || e.getSlot() == 37) {
    18. Bukkit.broadcastMessage("success");
    19. //accepted purchase
    20. }
    21. else if(e.getSlot() == 7 || e.getSlot() == 8 || e.getSlot() == 16 || e.getSlot() == 17 || e.getSlot() == 25 || e.getSlot() == 26 || e.getSlot() == 34 || e.getSlot() == 35 || e.getSlot() == 43 || e.getSlot() == 44) {
    22. Bukkit.broadcastMessage("decline");
    23. //decline purchase
    24. }
    25. }
    26. }


    Show Spoiler
    2014-06-16_12.23.09.png
    Show Spoiler

    2014-06-16_12.23.16.png
     
  2. Offline

    reider45

    The pastebin was removed? Please post your code :)
     
  3. Offline

    cfil360

  4. Offline

    Go Hard

    cfil360
    Whats happening? Stack traces? Need more information.
     
  5. Offline

    cfil360

    Go Hard like i said there are no stack traces. I solved it by adding a delay before opening the new inventory. Not sure if this is a bug or something i was doing.
     
Thread Status:
Not open for further replies.

Share This Page