Detecting if a chest has X amount of Y item

Discussion in 'Plugin Development' started by EggRoll, Sep 13, 2014.

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


    I'm currently developing something that uses BattleArena's API, that makes it so if I have 64 diamonds in the chest it would end the Battle.

    There's 2 chests and each team has their own chest in their own base. If a team has 64 diamonds in their chest, it ends the game.

    Is there a listener to check if there's 64 items in a unique chest?
  2. Offline



    1. private int getXItemsOfY(ItemStack Y){
    2. Inventory inv = yourInventory();
    3. int x = 0;
    4. if(inv.contains(y)){
    5. for(ItemStack item : inv.getContents()){
    6. if(y.equals(item)){
    7. x++;
    8. }
    9. }
    10. }
    12. return x;
    13. }

    something like this?
    EggRoll likes this.
  3. Offline


  4. Offline


    What I'm confused about is how to tell which chest is which since there are 2.

    Thanks for the help so far though :) I looked at the docs and just realized that it inherits the methods from Inventory.
Thread Status:
Not open for further replies.

Share This Page