1.15.2 onClickInventory event and hotbar keybind

Discussion in 'Spigot Plugin Development' started by Legora, Feb 17, 2020.

  1. Hello !
    Probably a basic error but...
    In a player's inventory i want to disable drop, mouse effect and keybord (keybind to quick move hotbar) on a specific item. Then i open a custom GUI.

    GUI open. Everything works fine with every case BUT using keyboard duplicate the item (being now in both slot, previous and new). As if it was cancelled but not really. Then GUI open.
    It's not just a visual/client bug, or at least the item is still there after dc+reconnect.


    Code (Text):
    public void onClickInventory(InventoryClickEvent event){
        if (event.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.YELLOW +"Menu")) {
            event.setCancelled(true);
            createInventory(player);
            return;
        }
    }
    What's strange for me is that it's actually triggering the event and open gui but not being cancelled by event.setCancelled()

    UPDATE : Only happens in creative, so it isn't that much of a problem but i'm still curious on the reason...

    Need a hint...
    Thanks guys !
     
    #1 Legora, Feb 17, 2020
    Last edited: Feb 18, 2020
  2. Is the item actually there or is it like a ‚ghost-item‘? In other words, once the inventory is closed, can you interact with the item as normal?
     
  3. Are you also listening for InventoryDragEvent?

     
  4. I have a - onPlayerInteract(PlayerInteractEvent e) - but only working when
    Code (Text):
    if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
    No InventoryDragEvent.


    Ah, i said it in my first message but it was not necessarly clear. It is not a ghost item that's why it's a problem :p
     
  5. UPDATE : Only happens in creative, so it isn't that much of a problem but i'm still curious on the reason...
     
  6. If it’s only happening in creative this might be a bug then?