Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve compatibility with custom NBT #183

Merged
merged 6 commits into from
Feb 17, 2024
Merged

Improve compatibility with custom NBT #183

merged 6 commits into from
Feb 17, 2024

Conversation

Jikoo
Copy link
Owner

@Jikoo Jikoo commented Feb 17, 2024

Improve compatibility with plugins that add arbitrary NBT. This works by copying the player's old data and writing the current data into it after removing a list of tags that the server is will not clobber if the corresponding internal values are not set. This does make updates marginally more complex, but a good chunk of the save code already needed to be reviewed, so it's not a huge deal.

This will not support ancient data versions - tags are not removed if they no longer exist in a supported version. It is assumed that when you upgrade your server you upgrade your world and players in a reasonable amount of time. In cases where data has not been upgraded in several major versions, it is possible that a very old tag may be preserved and clobber changes made via OI when it is converted into a modern copy.
For example, in 1.20 the tag ActiveEffects was replaced by active_effects. In 1.21, this will become an unsupported tag due to not having been present in the previous version. If a plugin were to load a player in 1.21 whose data had not been upgraded from the 1.19 format, OI would preserve the ActiveEffects tag, which would likely clobber any data in active_effects next load. This would result in potion effects appearing to not save.

Closes #182

Will later be replaced by more robust support for arbitrary non-vanilla NBT tags
Rather than expanding tag preservation, preserve all tags that are not known tags that may not be clobbered by the save process. This has the side benefit of more easily preserving vehicles and the previously-missed shoulder entities. Session timestamp tags still need to be reverted.
Affected only vanilla players who had never logged in on a Craftbukkit-based server
Using a prefix does save a couple lines of text, but also means that non-vanilla tags like "Spawner" etc. would be deleted. Anyone using a namespace prefixed with "Bukkit" should also be using a Bukkit-supported save method, so that should always be safe. Other server implementation tags that I've viewed ("Spigot"- and "Paper"-prefixed) are written every time.
Shoulder entities are actually loaded and kept in memory as a CompoundTag. As they aren't read into the world unless evicted from the shoulder, they should be saved properly, so preserving them would cause entity duplication.
Adds backwards compatibility for deleting migrated active effects tag. In the future, these backwards compatibilities will be maintained only for the current supported versions, i.e. when 1.21 comes out, the 1.19 module will be dropped, and 1.21 will not contain 1.19 backwards compatibility.
@Jikoo Jikoo merged commit 6f8a6e8 into master Feb 17, 2024
3 checks passed
@Jikoo Jikoo deleted the dev/nbt-compat branch February 17, 2024 03:41
Jikoo added a commit that referenced this pull request May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inventory Loss when editing inventory in another non-main world
1 participant