Closed hazae41 closed 5 years ago
Can you go into more details? Which metadata specifically?
The metadata of blocks and entities https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/metadata/Metadatable.html Every metadata is cleared at reboot, that's annoying for plugin developers and it was an issue in Bukkit. (We could no longer use config files with block location or entity uuid to save data.)
So if I'm understanding this correctly, the Spigot "Metadata" API is a plugin feature, correct? As in, the server implementation doesn't use it for its own internals, but it allows plugins to attach extra information about blocks and entities?
I don't see an issue in implementing the persistence. Is there documentation on how Spigot saves this data? Is it a custom format in the world files we need to support for world migration?
You can find how it is saved here (it is a simple HashMap) https://github.com/TacoSpigot/Bukkit/blob/master/src/main/java/org/bukkit/metadata/MetadataStoreBase.java And the implementation in blocks, entities, players, worlds [removed]
The goal is to save it to a file so when the server restarts the data is still available
@hazae41 I removed the link to the CraftBukkit fork as using it as a reference is against section 4 of our CLA.
If no documentation is available for how metadata is persisted on disk, we'll have to reverse-engineer it.
In fact, it is currently not persisted on disk with Spigot/CraftBukkit, that's the point of the enhancement
Do you know if there's a reason Spigot doesn't persist it? It might've been by design.
No one knows
This Bukkit thread introducing this feature mentions that metadata isn't persistent, without giving a specific reason why.
It might be good to remember that the original Bukkit team was reluctant to modify the Vanilla storage containers. This might be a reason it wasn't part of the original design.
Also, from a technical standpoint, we'd have to limit the type of metadata values probably to what NBT supports, which may be inconsistent with the Spigot implementation.
Maybe relevant: Sponge discussion on the matter from the original author of the metadata API: https://forums.spongepowered.org/t/persistent-metadata-api/1188
Closing because the expected behavior is to not persist the metadata. If this changes in later versions, or if a new API is defined, persistence will be added.
This would be useful