Checking if the player contains 2240 of an Item

Discussion in 'Plugin Development' started by nuno1212sss, Mar 4, 2014.

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

    nuno1212sss

    Hi boys n girls,
    I'm trying to check if a player's inventory contains an itemstack with 2240 blocks, and it does, but it says that is doesn't ...

    Code:java
    1. ItemStack im = new ItemStack(Material.getMaterial(Integer.parseInt(strings[0])), 2240, (byte) Integer.parseInt(strings[1]));
    2. if(p.getInventory().contains(im)){
    3. try{
    4. p.getInventory().remove(im);
    5. p.updateInventory();
    6. Util.sendCompra(p, ChatColor.RED +"Não tens isso no teu inventário!");
    7. }
     
  2. Offline

    TryB4

    nuno1212sss
    p.getInventory().containsAtLeast(Material, amount)
     
  3. Offline

    nuno1212sss

    TryB4 And how do I remove ?
     
  4. Offline

    GaaTavares

    Loop through his contents (p.getInventory().getContents()) check if the itemstack isn't null, then check the type and remove it.
     
  5. Offline

    nuno1212sss

    GaaTavares likes this.
Thread Status:
Not open for further replies.

Share This Page