My InventoryClickEvent is called twice per click?

Discussion in 'Plugin Development' started by EssentialsPissesMeOff, Nov 21, 2019.

Thread Status:
Not open for further replies.
  1. When i press a button in my gui, the message that is supposed to say "Test" is run twice when i press the button only once.

    Code:
                ArrayList<UUID> testArray = new ArrayList<>();
    public void openFirstPage(InventoryClickEvent e) {
        Player player = (Player) e.getWhoClicked();
        if (!e.getInventory().getName().equalsIgnoreCase("§8§lTest")) {
            return;
        }
    
    if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Test")) {
                    event.setCancelled(true);
                    player.closeInventory();
                    if (player.hasPermission("test.test")) {
                        test.add(player.getUniqueId());
                    }
                    else {
                        player.sendMessage("Test");
                    }
                }
    }
     
  2. Offline

    CraftCreeper6

  3. Technically speaking, i have my InventoryClickEvent, and in this event method i have 2 other methods for 2 different pages of my gui, but i cant really see how this would conflict with each other.
    Code:
        @EventHandler
        public void onInvClick(InventoryClickEvent e) {
            openFirstPage(e);
            openSecondPage(e);
        }
    as for the reason i did that, not really sure, i guess just so its more organized.
     
  4. Offline

    CraftCreeper6

  5. nothing is triggering the onInvClick method to run, or even the openFirstPage/openSecondPage, it's only the contents within it that is being used separately from the whole method its a part of, so when i open one of the gui's, i dont think anything could cause it so both guis open at the same time.
     
Thread Status:
Not open for further replies.

Share This Page