Skip to content
Success

Changes

Summary

  1. #1230: Move unstructured PDC NBT serialisation to SNBT (details)
Commit f0661c3514a7d8e51e2281f045e1c14d0e733230 by md_5
#1230: Move unstructured PDC NBT serialisation to SNBT

The initial implementation of the CraftNBTTagConfigSerialiser attempted
to represent the entire NBT tree in yaml. While the tree structure
itself is nicely represented, the values and their respective types
become increasingly difficult to properly store in the context of
snakeyml/yml in general.

This is mainly due to the fact that nbt offers a lot of different types
compared to yaml, specifically the primitive arrays and different
floating point values are troublesome as they require parsing via mojang
parsers due to their custom format.

To build a future proof system for unstructured nbt in spigot yml,
this commit moves the entire serialisation fully into SNBT,
producing a single string as output rather than a full yml tree.
SNBT remains easily readable and editable for server owners, which was
one of the main criteria during the initial implementation of the
serialiser (preventing the use of bas64ed gzipped nbt bytes), while also
completely using mojangs parsing, eliminating any need for custom
parsing logic in spigot.

Additionally, a string allows for very straight forward handling of
legacy data by simply parsing strings as SNBT and maps/yml trees as
legacy content, depending on what type snakeyml produces after parsing
the yml content, removing the need for a versioning schema.
The file was modified src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
The file was modified src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java
The file was modified src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
The file was addedsrc/test/resources/pdc/legacy_pdc.yml
The file was modified src/test/java/org/bukkit/craftbukkit/inventory/PersistentDataContainerTest.java
The file was addedsrc/test/java/org/bukkit/craftbukkit/legacy/PersistentDataContainerLegacyTest.java