Solved ItemStack in ArrayList

Discussion in 'Plugin Development' started by shades161, Mar 19, 2016.

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

    shades161

    Quick question, I am working on a plugin and I need to get an item from an ArrayList, but, I need to know if Bukkit treats an itemstack of 10 sticks the same as an itemstack with 1 stick?

    This is probably simple, but I couldn't find the answer for when looking through an ArrayList using #contains()...

    Because I need it to make sure that it is not in there even if there is only 1 versus 10. (And I know I could use Materials but I need to keep the amount of items in the stack).

    Thank you for your help! And sorry if this is really silly.
     
  2. Offline

    DoggyCode™

    I don't know what you're trying to do.
     
  3. Offline

    shades161

    Sorry if I was confusing. What I am trying to do is compare ItemStacks. I have my new item, say 10 sticks, and I need to make sure that the ArrayList doesn't contain any sticks so that there isn't any duplication.
     
  4. Offline

    mcdorli

    No, contains shouldn't return the itemstack with 1 stick instead of the itemstack with 10 sticks, because they're 2 different objects. This is why we have ItemStack#isSimiliar(ItemStack otherItemStack) to check, if 2 itemstacks are the same in material
     
  5. Offline

    shades161

    @mcdorli Okay, thank you! That's all I needed.
     
Thread Status:
Not open for further replies.

Share This Page