How I can remove a number of renamed Items with ANY name?

Discussion in 'Spigot Plugin Development' started by sinnlosername, May 14, 2015.

  1. How I can remove a number of renamed Items with ANY name?
    With p.getInventory().removeItem(new ItemStack(Material.<Material>, <number>)); I only can remove items with the original name. :( plz help
    Its for a Shopping System with Clay bricks, iron ingots and gold ingots.

    Thanks in Advance :)
    • Like Like x 1
  2. Code (Java):
    if (item.getItemMeta().hasDisplayName()) {
  3. But it should do this with ANY Itemname.
  4. Yeah, that should work. Check if the item meta has a display name, remove the item if it does.
  5. If you remove a Item with the p.getInventory().removeItem(item); method it doesn't work with renamed Items
  6. It does, but not if you pass a new ItemStack as item. Because that new ItemStack you create doesn't have an ItemMeta or atleast no Displayname. You should loop through the inventory content, check if it has a display name and if it does remove that ItemStack, not a new one
  7. If you read the link:

    Ask about what you're attempting to accomplish by doing this.
  8. Loop over the contents and remove them manually, that gives you full control over what it removes.