Solved Additional permission for my /invsee Command

Discussion in 'Plugin Development' started by -L1nd-, Oct 17, 2018.

Thread Status:
Not open for further replies.
  1. Hey guys
    I´ve programmed a simple/invsee command.
    When I use the command, the inventory opens from the target. So I can also take things or pack them in.
    My question is now, is it possible (if so, how?) to prevent this, so that I can only view the inventory but not change it?
    I´ve no idea, how to do that.

    Best Regards L1nd
     
  2. Offline

    MrGeneralQ

    You can check if rhe inventory holder is a different player. If so , cancel player inventory click event

    Verstuurd vanaf mijn ONEPLUS A3003 met Tapatalk
     
  3. A ez way to do this would be to do this:

    Code:
    public class Listen implements Listener {
    
    @EventHandler
    public void onClick(InventoryClickEvent e){
          Player p = (Player)e.getPlayer();
          if(e.getInventory == INVENTORY){
                 e.setCancelled(true); //Cancels when they try to click and maybe u could close thier inventory aswell by doing p.closeInventory();
        }
    }
    
    }
    INVENTORY is the inventory btw if u did not catch that ;)
     
    Last edited: Oct 18, 2018
Thread Status:
Not open for further replies.

Share This Page