Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4399

ItemMeta.equals broken with AttributeModifiers

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Linux, Mac OS, also reported by various users

    • git-Spigot-f6a273b-1a7f2d1
    • Yes

      I have been using items with attribute modifiers for a long while, and I use ItemMeta.equals() to compare a stored ItemStack instance with the item in the player's hand, to make sure they're still holding the item I think they should be holding.

      This recently broke, and I believe it is due to this change:

      https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/8164f4b25bb557d4ded2db42ca4e6abb423bb5ee#src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java

      From what I can tell the compareModifiers check won't work because AttributeModifier doesn't implement hashCode, so two separate modifier instances that are functionally identical won't pass the contains() tests.

       

      I'll try to write a proper hashCod method and see if that fixes the issue.

       

            Unassigned Unassigned
            NathanWolf Nathan Wolf
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: