How to check if player has item with display name in inventory

Discussion in 'Plugin Development' started by Baklava, Aug 3, 2019.

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


    Hello! I am currently making a plugin that requires me to check if a player has an item with a specified display name in their inventory. I tried iterating through all the items in the player inventory like this
    for (ItemStack i : p.getInventory()) {
                                 if (i.getItemMeta().getDisplayName().equals("blah blah blah")) {
                                     //do whatever
    but without success. Does anybody know a way that works? thanks in advance!
  2. Online

    timtower Moderator Moderator

    @Baklava Check if i is null, check if there is itemMeta, check if there is a displayName
  3. Offline


Thread Status:
Not open for further replies.

Share This Page