Shopkeepers

Shopkeepers

2M Downloads

Item attributes disappearing between 1.21.1 and 1.21.4

Closed this issue ยท 6 comments

commented

Item attributes disappear when updating from 1.21.1 paper to 1.21.4 paper in items saved in shops.

This happens on the newest version of the plugin currently (Shopkeepers-2.23.5).

The issue seems to be caused by paper item meta serialization changes in 1.21.4 or other version.

The issue can be reproduced by:

1. Load 1.21.1 server with ItemEdit and Shopkeepers. (or other item edit plugin).
2. Save a shop with custom attributes (attack damage 1000 etc.).
3. Update to 1.21.4

4. The attributes are no longer working

Here is a example of attributes I tested the issue with:
Image

Both lore, item names and enchantments converted over correctly.

Here is a shopkeeper with a save with bugged item:

data-version: 3|2|4189
'1':
  uniqueId: 7f05785a-33c1-4a23-8d08-65dba648a38a
  world: world
  x: 6
  y: 77
  z: 22
  yaw: 178.05328
  type: admin
  name: ''
  object:
    type: axolotl
    baby: false
    axolotlVariant: LUCY
  recipes:
    '1':
      resultItem:
        ==: org.bukkit.inventory.ItemStack
        v: 4189
        type: DIAMOND_SWORD
        meta:
          ==: ItemMeta
          meta-type: UNSPECIFIC
          display-name: '{"text":"","extra":[{"text":"Testing sword","strikethrough":false,"obfuscated":false,"bold":false,"italic":false,"underlined":false,"color":"gold"}]}'
          lore:
          - '{"text":"","extra":[{"text":"Some lore","strikethrough":false,"obfuscated":false,"bold":false,"italic":false,"underlined":false,"color":"dark_gray"}]}'
          - '{"text":"","extra":[{"text":"Sharpness XXX","strikethrough":false,"obfuscated":false,"bold":false,"italic":false,"underlined":false,"color":"gray"}]}'
          - '{"text":"","extra":[{"text":"","strikethrough":false,"obfuscated":false,"bold":false,"italic":false,"underlined":false,"color":"dark_gray"}]}'
          enchants:
            minecraft:sharpness: 2
          attribute-modifiers: {}
          ItemFlags:
          - HIDE_ENCHANTS
          - HIDE_ATTRIBUTES
          - HIDE_UNBREAKABLE
          Unbreakable: true
      item1:
        ==: org.bukkit.inventory.ItemStack
        v: 4189
        type: ACACIA_LEAVES
        amount: 8
        meta:
          ==: ItemMeta
          meta-type: UNSPECIFIC
          display-name: '{"text":"","extra":["leaveCoins"]}'
          enchants:
            minecraft:mending: 1
          ItemFlags:
          - HIDE_ENCHANTS
    '2':
      resultItem:
        ==: org.bukkit.inventory.ItemStack
        v: 4189
        type: ACACIA_LEAVES
        meta:
          ==: ItemMeta
          meta-type: UNSPECIFIC
          display-name: '{"text":"","extra":["leaveCoins"]}'
          enchants:
            minecraft:mending: 1
          ItemFlags:
          - HIDE_ENCHANTS
      item1:
        ==: org.bukkit.inventory.ItemStack
        v: 4189
        type: ACACIA_LOG
  snapshots: []

Here is the save that should be there:

data-version: 3|2|4189
'1':
  uniqueId: 7f05785a-33c1-4a23-8d08-65dba648a38a
  world: world
  x: 6
  y: 77
  z: 22
  yaw: 178.05328
  type: admin
  name: ''
  object:
    type: axolotl
    baby: false
    axolotlVariant: LUCY
  recipes:
    '1':
      resultItem:
        ==: org.bukkit.inventory.ItemStack
        v: 4189
        type: DIAMOND_SWORD
        meta:
          ==: ItemMeta
          meta-type: UNSPECIFIC
          display-name: '{"text":"","extra":[{"text":"Testing sword","strikethrough":false,"obfuscated":false,"bold":false,"italic":false,"underlined":false,"color":"gold"}]}'
          lore:
          - '{"text":"","extra":[{"text":"Some lore","strikethrough":false,"obfuscated":false,"bold":false,"italic":false,"underlined":false,"color":"dark_gray"}]}'
          - '{"text":"","extra":[{"text":"Sharpness XXX","strikethrough":false,"obfuscated":false,"bold":false,"italic":false,"underlined":false,"color":"gray"}]}'
          - '{"text":"","extra":[{"text":"","strikethrough":false,"obfuscated":false,"bold":false,"italic":false,"underlined":false,"color":"dark_gray"}]}'
          enchants:
            minecraft:sharpness: 2
          attribute-modifiers:
            minecraft:attack_damage:
            - ==: org.bukkit.attribute.AttributeModifier
              amount: 10000.0
              slot: hand
              operation: 0
              key: minecraft:6ca71f96-8e7b-4231-928d-12bdde8c87a8
            minecraft:attack_speed:
            - ==: org.bukkit.attribute.AttributeModifier
              amount: -2.4
              slot: hand
              operation: 0
              key: minecraft:6dd3e1ce-ef68-4e5e-8659-84b458eca55e
          ItemFlags:
          - HIDE_ENCHANTS
          - HIDE_ATTRIBUTES
          - HIDE_UNBREAKABLE
          Unbreakable: true
      item1:
        ==: org.bukkit.inventory.ItemStack
        v: 4189
        type: ACACIA_LEAVES
        amount: 8
        meta:
          ==: ItemMeta
          meta-type: UNSPECIFIC
          display-name: '{"text":"","extra":["leaveCoins"]}'
          enchants:
            minecraft:mending: 1
          ItemFlags:
          - HIDE_ENCHANTS
    '2':
      resultItem:
        ==: org.bukkit.inventory.ItemStack
        v: 4189
        type: ACACIA_LEAVES
        meta:
          ==: ItemMeta
          meta-type: UNSPECIFIC
          display-name: '{"text":"","extra":["leaveCoins"]}'
          enchants:
            minecraft:mending: 1
          ItemFlags:
          - HIDE_ENCHANTS
      item1:
        ==: org.bukkit.inventory.ItemStack
        v: 4189
        type: ACACIA_LOG
  snapshots: []

Here is before and after with more simple item:

data-version: 3|2|3955
'1':
  uniqueId: fa47676a-3a6c-4e12-8d17-2007ee2a3dc8
  world: world
  x: 6
  y: 77
  z: 22
  yaw: 209.39743
  type: admin
  name: ''
  object:
    type: axolotl
    baby: false
    axolotlVariant: LUCY
  recipes:
    '1':
      resultItem:
        ==: org.bukkit.inventory.ItemStack
        v: 3955
        type: DIAMOND_SWORD
        meta:
          ==: ItemMeta
          meta-type: UNSPECIFIC
          attribute-modifiers:
            minecraft:generic.attack_damage:
            - ==: org.bukkit.attribute.AttributeModifier
              amount: 10000.0
              slot: hand
              operation: 0
              key: minecraft:2eafde15-cd4e-43b3-9354-e7f8e1bb4d76
      item1:
        ==: org.bukkit.inventory.ItemStack
        v: 3955
        type: ACACIA_LEAVES
  snapshots: []
data-version: 3|2|4189
'1':
  uniqueId: fa47676a-3a6c-4e12-8d17-2007ee2a3dc8
  world: world
  x: 6
  y: 77
  z: 22
  yaw: 209.39743
  type: admin
  name: ''
  object:
    type: axolotl
    baby: false
    axolotlVariant: LUCY
  recipes:
    '1':
      resultItem:
        ==: org.bukkit.inventory.ItemStack
        v: 4189
        type: DIAMOND_SWORD
      item1:
        ==: org.bukkit.inventory.ItemStack
        v: 4189
        type: ACACIA_LEAVES
  snapshots: []

/version command output:

This server is running Paper version 1.21.4-229-ver/1.21.4@e2ca477 (2025-05-09T15:52:06Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT) You are 1 version(s) behind Download the new version at: https://papermc.io/downloads/paper Previous version: 1.21.1-21-cfa3c61 (MC: 1.21.1)

commented

I am not able to reproduce the issue on Spigot 1.21.4 (latest build: 4458).

With Paper (1.21.4-226-ver/1.21.4@a838a88 (2025-04-17T19:20:57Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)) I am able to reproduce the issue. The same applies to the latest version (1.21.4-231-ver/1.21.4@09e9afd (2025-05-19T17:59:36Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)). And I can reproduce the issue when trying to update directly to Paper 1.21.5.

My guess is that something goes wrong during the mapping of the older attributes names to Minecraft attribute names. For instance, if I manually edit the example save file and replace minecraft:generic.attack_damage with minecraft:attack_damage, the attribute loads fine.

I am not completely sure what the difference is between Spigot and Paper in this area. The code looks mostly the same to me.

So I think this are your options to solve this currently:

  • Report this to Paper: I think this would be something for Paper to investigate and fix.
  • If you save file is small, manually edit it and convert all attribute names according to the mapping found in the server source code: https://github.com/PaperMC/Paper/blob/main/paper-server/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java#L363
  • Since loading the item on a Paper 1.21.1 server works, another potential solution could be to do the following:
    • Run the shopkeeper snapshot version linked in this ticket on a Paper 1.21.1 server: #958
      This should convert all items in the save file to a new storage format.
    • Then run the same shopkeeper snapshot version on your 1.21.4 server and load the migrated save file there.
    • I briefly tested this with your minimal example save file and this worked.
commented

I will open a issue on paper with linking this issue (if there is not one already open). This seems to be issue on paper instead of any plugin, since there are multiple plugins that break similarly when moving from 1.21.1 to 1.21.4+

Do you know the exact method that is used for saving and retrieving the items? I'll add it into the paper issue.

commented

Seems to be ConfigurationSerializable.serialize() and ConfigurationSerialization.deserializeObject(). Correct me if I am wrong.

commented

Serializing ItemMeta seems to be no longer supported, and there might not be a fix at all. Moving to a different format would probably be the best.

Here is the paper issue I opened: PaperMC/Paper#12577

commented

Serializing ItemMeta seems to be no longer supported, and there might not be a fix at all. Moving to a different format would probably be the best.

Here is the paper issue I opened: PaperMC/Paper#12577

So checkout the two other solutions I proposed above.

commented

Shopkeepers v2.23.6 is now released and includes the changes to the serialization of item data mentioned for the above linked snapshot version. I consider this ticket resolved from my side: There likely won't be an automatic solution that supports updating directly from the old save format to the new server and plugin version, but you can get the old data working by following the above mentioned approach of first running the new v2.23.6 plugin version on an older still working server version, and then upgrading to a newer server version.

The new item save format should hopefully be less prone to breaking changes going forward (unless the server or Mojang itself introduces bugs or major changes to the item format).