Identifying and handling custom inventory

Discussion in 'Plugin Development' started by bennie3211, Aug 16, 2022.

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

    bennie3211

    Hi all,

    Can someone point out to me how to get the name of a custom inventory? I am trying to cancel manipulations through the InventoryClickEvent, but can't find a way to differentiate my custom inventory from any other inventory type.

    Another question is if I need to monitor more events to disable the manipulation of a custom inventory, I want to use the inventory to display some items and prevent the player from manipulating the inventory.

    Thanks!
     
  2. Offline

    Smeary_Subset

    Why do you need to use the name? You can just see if event#getInventory()#equals(yourInventory)
     
  3. Offline

    KarimAKL

    The only event related to removing items from inventories is the InventoryClickEvent. However, if you also want to stop people from putting items into the inventory, you would also need to listen to the InventoryDragEvent in addition to the aforementioned event.

    Regarding inventory names, you have to get them from the InventoryView instance, which you can get from the inventory events using the InventoryEvent#getView() method. The name of an inventory view is called a title. You get it using the InventoryView#getTitle() method.
     
Thread Status:
Not open for further replies.

Share This Page