Counting individual blocks

Discussion in 'Spigot Plugin Help' started by NavyDev, Jun 30, 2016.

  1. Right, there is probably some sort of really obvious answer to this. But i cant seem to find it. Its late and i guess i "hit the wall" xD

    Anyway. What i am looking for, is some code that will check for an item and then count how many of that item (or block) is inside the players inventory.

    Here is something along the lines of what i'm thinking (PSEUDOCODE)

    Code (Text):
    Stone = 0
    public void onClose (InventoryCloseEvent player)
    if player.getInventory.contains(Material.STONE)
    Material.Stone.getAmount(Stone)

    Idfk...

    But that is something along the lines that i want i guess... I just cant seem to bridge it...

    P.s Its PSEUDOCODE so dont worry about correcting my formatting or what ever, i know its wrong xD

    Thank you,

    - Navy
     
  2. How about taking a look into the Javadocs?
    org.bukkit.inventory.Inventory#all(...)
    Sounds exactly like what you need, doesn't it?

    EDIT: Furthermore this should be moved here: https://www.spigotmc.org/forums/spigot-plugin-development.52/
     
    • Winner Winner x 1