Check players inventory

Discussion in 'Plugin Development' started by CptnPummeluff, May 31, 2014.

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

    CptnPummeluff

    Hey, how do I check if a players inventory contains for example 20 redstone? Thanks :)
     
  2. Offline

    CraftCreeper6

    CptnPummeluff

    Code:java
    1. if(p.getInventory().contains(ITEM)){
    2. } else {
    3. }
     
    es359 likes this.
  3. Offline

    CptnPummeluff

    CraftCreeper6 Yes ofc, but I want to check if the players inventory contains an amount of items
     
  4. Offline

    Arkel

    ItemStack.java
     
    Dealyise likes this.
  5. Offline

    Dealyise

    Was just about wo write the same, use ItemStack for it.
     
  6. Offline

    CptnPummeluff

    I know, but how do I combine that with a if?
    Code:java
    1. if(p.getInventory().contains()){
    2. //code here
    3. }
     
  7. Offline

    Konkz

    Loop through the inventory and if they have certain item remove it
     
  8. Offline

    Arkel

    If you don't know how to combine that with an if statement it would be helpful for you to follow some more java tutorials before continuing. See Learning Java
     
    Konkz and Dealyise like this.
  9. Offline

    Dealyise

    Just use a new ItemStack:
    Code:java
    1. if(player.getInventory().contains(item)){
    2. //Code here
    3. }else{
    4. //Code here
    5. }
     
Thread Status:
Not open for further replies.

Share This Page