Solved GUI InventoryClickEvent not functioning

Discussion in 'Plugin Development' started by bijx, Apr 5, 2016.

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

    bijx

    I am making a GUI for a plugin and when I implement the InventoryClickEvent, it wont function at all. I wrote the following:

    Code:
    @EventHandler
    public void onInventoryClick(InventoryClickEvent e){
    getLogger().info("[Debug] Inventory Clicked");
    if(!ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase("GUI"))
        return;
    Player player = (Player) e.getWhoClicked();
    e.setCancelled(true);
    
    }
    The inventory itself pops up properly with its named items, but when I click it, it won't do what I set it to do. So what I did was I added a debug console message right at the beginning of the click event to see if it worked (right before the if-statement), and surely it didn't output anything.

    What must I do here to fix this? I am using Spigot 1.9 and this is all taking place inside my main class.
     
  2. Offline

    RenditionsRule

    Does your main class implement Listener? If so, did you register the event in the onEnable?
     
  3. Offline

    Elimnator

    Yah, I had this problem randomly sometimes clicking in our inv won't trigger the InventoryClickEvent.
    IDK why, must be a bug.
     
  4. Offline

    bijx

    Aha! That was indeed my issue. I don't normally use the listener in the main, so I forgot to add that. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page