From e190aa6b33d63d128b9bbf83c1bb9601e773ddea Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Wed, 24 Apr 2024 17:53:14 +1000 Subject: [PATCH] SPIGOT-7625: ItemStack with lore cannot be serialized in 1.20.5 By: DerFrZocker --- .../bukkit/craftbukkit/inventory/CraftMetaItem.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index 235323cdb8..d3577d027b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -1481,8 +1481,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { builder.put(ITEM_NAME.BUKKIT, CraftChatMessage.toJSON(itemName)); } - if (lore != null) { - builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore)); + if (hasLore()) { + // SPIGOT-7625: Convert lore to json before serializing it + List jsonLore = new ArrayList<>(); + + for (IChatBaseComponent component : lore) { + jsonLore.add(CraftChatMessage.toJSON(component)); + } + + builder.put(LORE.BUKKIT, jsonLore); } if (hasCustomModelData()) {