To check items in a chest.

Discussion in 'Spigot Plugin Help' started by BruteForcePvpOG, May 31, 2017.

  1. Hello, my name is BruteForcePvp. I'm currently making a custom plugin, I would like to know if there is anyway to check what items are in a chest? Thank you

    -Brute
     
  2. Here you can test whether the chest contains a diamond:
    Code (Text):

    Chest chest = (Chest) e.getBlock();
    chest.getBlockInventory().contains(Material.DIAMOND);
     
     
    • Optimistic Optimistic x 1
  3. Would you not need to cast the blockState() rather than just the block to Chest?
    I believe it should be:
    Code (Text):
    Chest chest = (Chest) e.getBlock().getState()
    //Rest of the code here
     
  4. hey,
    when you have some questions, write me a private meesage.
    Good plugin idea :)