1.14.4 Hello i need some help here!

Discussion in 'Spigot Plugin Development' started by xMaikiYT, Mar 31, 2020.

  1. hello! how i can do that:

    if player have an itemStack in the inventory!
     
  2. SteelPhoenix

    Moderator

    Inventory#contains()
     
    • Informative Informative x 2
  3. You just check it by using, if(player.getInventory().contains(Material.STICK)) {} for example.
     
    • Like Like x 1
  4. iirc #contains checks for item count. so if you provide an item with only 1 count and you have an itemstack with a count of 2, it returns false (i could be wrong about this, should do some testing, but incase you have an issue). #containsAtLeast and manually providing a 1 as the int for 1 of those itemstacks should get you what youre looking for if #contains has weird issues.
     
  5. Two suggestions;
    1. You look up your issue before you create a thread.
    2. If it comes down to making a thread, the title is designed to specify what kind of issue you are having.
      1. "Trying to find item inventory"
      2. "How to check inventory contents?"
      3. etc..