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

replacing an enchantment on an item creates a conflict error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • 07.07 22:45:50 [Server] Server thread/INFO This server is running CraftBukkit version 3172-Spigot-610a8c0-99561c2 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) 07.07 22:45:50 [Server] Server thread/INFO Checking version, please wait... 07.
    • Yes

      If you use the API to remove an enchantment from an item, then re-add that same enchantment with a different level, then call getEnchantments() on that item the following error is thrown:

      https://hatebin.com/rbhqaqvqqn

       

      If you drop the item and pick it back up the error does not re-appear.  Thus it appears that maybe the old enchantment isn't properly being removed by removeEnchantment()

       

      code example:

       

      ItemStack is = plr.getInventory().getItemInMainHand();
      is.addEnchantment(Enchantment.DURABILITY, 2);
      is.removeEnchantment(Enchantment.DURABILITY);
      is.addEnchantment(Enchantment.DURABILITY, 3);
      if(is.getEnchantments() != null)
          system.out.println("found enchantment");
       
      

       

      The above sample would simulate adding an enchantment to an itemstack, then removing it, then adding back the same enchantment with a different level.   This seems to leave two entries with the same key in the map, when getEnchantments() is called the error is thrown, this error will be thrown every time getEnchantments() is called until the item is dropped then picked back up, (it may also fix itself if the user logs out/in again).

       

            Unassigned Unassigned
            whoolieshop Shane Martin
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: