Invsee Cancel InventoryClickEvent while in player's inventory

Discussion in 'Plugin Development' started by stunni, Nov 2, 2022.

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

    stunni

    Hi, I'm trying to make it so you can't click while viewing a player's inventory using "/invsee" I have the command and it works completely fine. The only issue is the listener, I don't know how to tell the plugin with (if(e.getInventory().equals("Inventory")) { what kind of inventory it is because I don't know what the player's inventory is called.
     
  2. Offline

    Kars

    Are you able to execute your code?
    Do a remote debugging, put a breakpoint there. Then save e.getInventory into a variable so you can view its properties.
     
    LABSTORM likes this.
  3. Offline

    LABSTORM

    Haven't tested, but
    Code:
    if(e.getInventory().getHolder() instanceof Player) {
    e.setCancelled(true)
    }
    
    might work...
    Or maybe even just
    Code:
    if (e.getInventory() instanceof PlayerInventory) {
    e.setCancelled(true)
    }
    
     
Thread Status:
Not open for further replies.

Share This Page