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

Serialized ItemStack Lore Doesn't Deserialize

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • 1.14 Pre-Release 5, Mac OS / Linux

    • git-Spigot-dc58fe4-14df075 (MC: 1.14 Pre-Release 5)
    • Magic
    • Yes

      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.

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

              Created:
              Updated:
              Resolved: