highest amount

Discussion in 'Plugin Development' started by DevManABCD, Jul 21, 2014.

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

    DevManABCD

    can i check if amount of cobblestone in player inventory is highst than 128?
     
  2. Offline

    Traks

    How about this?
     
  3. Offline

    fireblast709

    DevManABCD loop over the contents, check if its cobble, add the amount to a method variable and return whether that is greater or equal than 128
     
    DevManABCD likes this.
  4. Offline

    DevilMental

    DevManABCD So just put this code into the method you want, and more importantly, try to understand it.
    Code:java
    1. //Considering p is the Player
    2. for (ItemStack i : p.getInventory().getContents()){
    3. if (i != null && i.getType() == Material.COBBLESTONE){ // If the item is not null and the type is cobble
    4. if (i.getAmount() >= 128){ // If the amount is higher or equal to 128 then...
    5. // Do what you want
    6. }
    7. }
    8. }
     
  5. Offline

    DevManABCD

    That was useful, thanks.
     
Thread Status:
Not open for further replies.

Share This Page