[SPIGOT-4736] Serialized ItemStack Lore Doesn't Deserialize Created: 24/Apr/19  Updated: 25/Apr/19  Resolved: 25/Apr/19

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Nathan Wolf Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: 1.14, itemstack, serialization
Environment:

1.14 Pre-Release 5, Mac OS / Linux


Version: git-Spigot-dc58fe4-14df075 (MC: 1.14 Pre-Release 5)
Plugin: Magic
Guidelines Read: Yes

 Description   

ItemStack serialization looks a little broken, it is now serializing lore as NMS ChatComponent, but it can't deserialize it that way.

To reproduce, serialize an ItemStack with lore to Yaml, you will get something like this:

item:
      ==: org.bukkit.inventory.ItemStack
      v: 1951
      type: WOODEN_HOE
      meta:
        ==: ItemMeta
        meta-type: UNSPECIFIC
        display-name: §6Fling§f (§3The Wolf§f)
        lore:
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}
        - !!net.minecraft.server.v1_14_R1.ChatComponentText {}

Then attempting to deserialize the item will result in an error:

[10:27:59] [Craft Scheduler Thread - 0/ERROR]: Cannot load plugins/Magic/data/players/4cb358ae-719c-4423-93c7-8769ce46e9c3.dat
org.bukkit.configuration.InvalidConfigurationException: could not determine a constructor for the tag tag:yaml.org,2002:net.minecraft.server.v1_14_R1.ChatComponentText
 in 'string', line 559, column 11:
            - !!net.minecraft.server.v1_14_R1. ... 
              ^


	at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:56) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:160) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:128) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:183) [spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at com.elmakers.mine.bukkit.data.YamlMageDataStore.load(YamlMageDataStore.java:103) [Magic.jar:?]
	at com.elmakers.mine.bukkit.magic.MagicController$1.run(MagicController.java:386) [Magic.jar:?]
	at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftTask.run(CraftTask.java:81) [spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:51) [spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
Caused by: org.yaml.snakeyaml.constructor.ConstructorException: could not determine a constructor for the tag tag:yaml.org,2002:net.minecraft.server.v1_14_R1.ChatComponentText
 in 'string', line 559, column 11:
            - !!net.minecraft.server.v1_14_R1. ... 
              ^


	at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructUndefined.construct(SafeConstructor.java:541) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:204) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:193) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructSequenceStep2(BaseConstructor.java:364) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructSequence(BaseConstructor.java:348) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlSeq.construct(SafeConstructor.java:499) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:204) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:193) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndStep(BaseConstructor.java:453) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep(SafeConstructor.java:184) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseConstructor.java:434) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct(SafeConstructor.java:521) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.construct(YamlConstructor.java:28) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:204) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:193) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndStep(BaseConstructor.java:453) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep(SafeConstructor.java:184) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseConstructor.java:434) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct(SafeConstructor.java:521) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.construct(YamlConstructor.java:28) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:204) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:193) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndStep(BaseConstructor.java:453) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep(SafeConstructor.java:184) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseConstructor.java:434) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct(SafeConstructor.java:521) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.construct(YamlConstructor.java:28) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:204) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:193) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndStep(BaseConstructor.java:453) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep(SafeConstructor.java:184) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseConstructor.java:434) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct(SafeConstructor.java:521) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.construct(YamlConstructor.java:28) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:204) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:193) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndStep(BaseConstructor.java:453) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep(SafeConstructor.java:184) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseConstructor.java:434) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct(SafeConstructor.java:521) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.bukkit.configuration.file.YamlConstructor$ConstructCustomObject.construct(YamlConstructor.java:28) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:204) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:193) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:159) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:146) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:524) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.yaml.snakeyaml.Yaml.load(Yaml.java:437) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:54) ~[spigot-1.14-pre5.jar:git-Spigot-dc58fe4-14df075]
	... 10 more

I could write a test plugin if needed.


Generated at Sat Apr 05 10:22:53 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.