This server is running CraftBukkit version git-Spigot-a19903d-e1ebdd9 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT)
So it is quite straight forward.
Whenever an item's name is modified by the anvil, serialized, and then de-serialized, then isSimilar() now no longer able to tell they are the similar items.
Take a look at the screenshots for details.
- Rename any item with anvil
- Copy the item through creative inventory (As shown in the screenshot)
- Check if they are indeed similar. At this point, they are similar as shown in screenshot.
- Now, do the following steps
- Save item using the FileConfiguration (using getConfig() method of the JavaPlugin class)
- Save the FileConfiguration into String
- Create a new YamlConfiguration and load the serialized String from 4.2.
- Get the ItemStack from the YamlConfiguration
- Now, again, check if they are similar just like I did in process 3.
- Now isSimilar() returns false for some unknown reason.
Since the toString() of both ItemStack shows exactly same output, I assume something is internally failing.
I think this is a major issue since it's a quite basic functionality. Item name is something that can be easily changed in-game without any plugins. Plugins that rely on isSimilar() method will be severely impacted by this problem.
PS) test code attached here