Skip to content
Success

Changes

Summary

  1. SPIGOT-7608: Allow empty lists to morph to any PDT list (details)
Commit ffd15611c7060628adaf5410a10513a8c1efdc68 by md_5
SPIGOT-7608: Allow empty lists to morph to any PDT list

The minecraft serialisation logic for ListTag updates the type byte of
the list tag during writing to match either the first element in the
list or 0, if said list tag is empty.
As such, list content type information cannot be carried through a
write/read process, e.g. chunk load/unload or a creative client updating
the item.

The recently introduced persistent data type collections for lists hence
can also not enforce a specific list content type if the found list is
empty, which it currently attempts to do.
As such, a call to PersistentDataContainer#has would also yield false
for any empty list as the lists type byte would be 0.

The faulty behaviour has been fixed by considering an empty list in the
persistent data container to match any list type.
This change, while technically breaking the #has check, is needed and
reasonable as the #has check for this is currently broken in the first
place as described above.
The file was modified src/test/java/org/bukkit/craftbukkit/inventory/PersistentDataContainerTest.java
The file was modified src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataTypeRegistry.java