GlowstoneMC / Glowstone

A fast, customizable and compatible open source server for Minecraft: Java Edition
https://glowstone.net
Other
1.88k stars 271 forks source link

Add metadata persistence #1041

Closed hazae41 closed 5 years ago

hazae41 commented 5 years ago

This would be useful

aramperes commented 5 years ago

Can you go into more details? Which metadata specifically?

hazae41 commented 5 years ago

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.)

aramperes commented 5 years ago

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?

hazae41 commented 5 years ago

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

aramperes commented 5 years ago

@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.

hazae41 commented 5 years ago

In fact, it is currently not persisted on disk with Spigot/CraftBukkit, that's the point of the enhancement

aramperes commented 5 years ago

Do you know if there's a reason Spigot doesn't persist it? It might've been by design.

hazae41 commented 5 years ago

No one knows

aramperes commented 5 years ago

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

aramperes commented 5 years ago

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.