1.16.5 How to check that items have the same custom name

Discussion in 'Spigot Plugin Development' started by StTrigger, Jul 19, 2021.

  1. So basically I'm making a plugin with custom armor with abilities, but the problem is that every time armor getting damaged it's stops passing the itemstack test. So I wanna check items have the same custom name, and also I want it to don't create bulls, anybody know how to do that?
  2. Rather then names, you should consider using the persistent data since you are on 1.16.5, its signficiantly more stable. But specific to your question, you can check if the item has a meta (a method exists.), fetching the meta, checking if the meta has a displayname, and checking if that name is of your wanted item.
  3. Yeah ik that but that's creating a hell lot of. Nulls
  4. So make checks before? Having PersistentDataContainer is a blessing from Mojang to all plugin developers - it literally brought us from the stone age of relying on names to the modern age! And you want to dismiss that and work with names cuz "ew, maybe null..."?!
    • Agree Agree x 1
  5. can you give me some example with that?
  6. You can find a guide to PDC here.
  7. item#getItemMeta#getDisplayName. Takes 5 seconds to find it on google :)