Paper
Paper copied to clipboard
Incorrect serialisation or deserialisation causes not deserializable ItemStacks
Expected behavior
Be able to load the serialized ItemStack from yaml
Observed/Actual behavior
The following exception: https://cpaste.de/xisomajoto.sql
Steps/models to reproduce
The ItemStack is modified like this:
ItemMeta itemMeta = item.getItemMeta();
PersistentDataContainer persistentDataContainer = itemMeta.getPersistentDataContainer();
// String content = new JSONArray(activeArmorParticleNamesList).toString();
String content = "[\"UnicornParticle\",\"TotemParticle\",\"AngelParticle\",\"ColorSwitchParticle\"]"
persistentDataContainer.set(plugin.getAddedParticlesNamespacedKey(), PersistentDataType.STRING, content);
item.setItemMeta(itemMeta);
Now I am now serializing and then deserializing the ItemStack like this:
YamlConfiguration conf = new YamlConfiguration();
conf.set("item", item2);
YamlConfiguration conf2 = new YamlConfiguration();
try {
conf2.loadFromString(conf.saveToString());
} catch (Exception e) {
Bukkit.getLogger().log(Level.SEVERE, conf.saveToString(), e);
}
Plugin and Datapack List
n/a
Paper version
git-Paper-"38be4f8" (MC: 1.19.4) (Implementing API version 1.19.4-R0.1-SNAPSHOT) (Git: 38be4f8)
Other
No response
This is likely an upstream issue down to how the PDC is serialised into the yaml format; easy fix would be to just store the encoded NBT rather than being stupid about it and trying to store structured data which cares about type info into a system which doesn't even understand types
To give a little more context, the broken and not good bukkit serialization system tries to deserialize that string as a list since it looks like [item1, item2]
.