Development Assistance Check if inventory contains item

Discussion in 'Plugin Help/Development/Requests' started by Koningpeter, May 17, 2015.

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

    Koningpeter

    I want to check if the inventory contains 30 Stone Brick Slabs, but this code doesn't work....
    Can someone help my?

    This is my code:
    if(!(p.getInventory().contains(Material.STEP, 30, (short)5))){
    p.sendMessage(ChatColor.RED + "You don't have 30 Stone Brick Slabs.");
    return false;
    }
     
  2. @Koningpeter Contains isn't 3 arguments, it needs an itemstack. Just check for a new itemstack with all them args.
     
    Koningpeter likes this.
  3. Offline

    Koningpeter

    Can you give my the code?
     
  4. Offline

    Koningpeter

    @bwfcwalshy
    This doesn't work too....

    if(!(p.getInventory().contains(new ItemStack(Material.STEP, 30, (short) 5)))){
    p.sendMessage(ChatColor.RED + "You don't have 30 Stone Brick Slabs.");
    return false;
    }
     
  5. Offline

    I Al Istannen

  6. Offline

    Koningpeter

    @I Al Istannen
    But how can I use (short)
    I have Material and amout.....
     
  7. Offline

    I Al Istannen

    @Koningpeter short? What do you want to do with this? If you just need "amount" "material" use the first link.
     
  8. Offline

    Koningpeter

    @I Al Istannen
    Material.STONE_BRICK_SLAB does not exist
    You need Material.STEP, (short) 5
     
Thread Status:
Not open for further replies.

Share This Page