How can I deny access to people opening chests?

Discussion in 'Spigot Plugin Development' started by Zaiden, May 18, 2016.

  1. Hello Im wondering how to deny access to chests?

    Im am making my own privated chests plugin

    any help will be appreciated

  2. Cancel PlayerInteractEvent if the block clicked was a chest.
  3. Code (Text):
    public void onInventoryOpen(InventoryOpenEvent event) {
       if (event.getInventory().getType() == InventoryType.CHEST) {
    What this code is doing, is when you right click a chest, and the menu opens, it calls the InventoryOpenEvent. Here, you are listening for the event, and if the inventory type is equal to a chest, then you cancel the event, therefore not opening the chest.

    @PickNChew's method works just as well too.
  4. Also you would need a config to store who can open the chest
    • Optimistic Optimistic x 1