Check for chest name in InventoryCloseEvent

Discussion in 'Spigot Help' started by MeneerValk, Jun 13, 2021.

  1. I'm making a spigot plugin and need to only run my code if the chest that is closed, has a certain name.

    How could I add a check for that?



    My code:

    public void chestCloses(InventoryCloseEvent event) {
    if (event.getInventory().getType().equals(InventoryType.CHEST)) {
    ....
    }
    }
     
  2. For future reference, this belongs in the Spigot Plugin Development section.

    To get the name of the inventory you'll need to use
    Code (Java):
    event.getView().getTitle()
    Per the javadocs.
     
    • Like Like x 1