fix: keep item meta on chest items (1.26.2) - #543
Merged
Conversation
Chest files have been read with plain SnakeYAML since 1.26.0 so that an item unknown to the server version can be skipped individually instead of taking down the whole file. That left every nested value as a plain map, including an item's meta section, and ItemStack.deserialize silently ignores meta that is not already an ItemMeta. Enchanted books, potions, custom names and anything else meta-carrying arrived stripped: players in Plains were getting enchanted books with nothing stored on them. Chest item maps are now walked depth first and any map carrying a "==" type key is deserialized through ConfigurationSerialization before the item is built, so meta is a real ItemMeta by the time Bukkit sees it. A part that cannot be deserialized is left as a map and logged, so a bad meta section costs its meta rather than the whole item. Verified on a real Paper 26.2 server against the shipped phase files: 1.26.0 gave 0/3 Plains enchanted books with enchantments, this gives 3/3. The legacy enchantment names in the phase YAML (PROTECTION_FALL and friends) are still remapped by CraftBukkit, so no phase file changes are needed. Bumps version to 1.26.2. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SAQ3YQkcfRoCZEwa6SPJcp
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
Players report chest loot arriving inert — the reported case was Plains enchanted books with no enchantments on them.
Since 1.26.0, chest files are read with plain SnakeYAML rather than
YamlConfiguration, so that an item unknown to the server version can be skipped individually instead of taking down the whole file. Nothing is deserialized on the way in, though, so an item'smeta:section reacheschestItem()as a plainMap— andItemStack.deserializeonly applies meta that is already anItemMeta:The meta is dropped silently. This affects every meta-carrying chest item in every phase — potions, tipped arrows, custom-named items, banners, heads, written books — not just the books.
Not a phase-file problem: the legacy enchantment names in the YAML (
PROTECTION_FALL,DAMAGE_ALL, …) are still remapped by CraftBukkit viaFieldRename.ENCHANTMENT_DATA, which is built.forAllVersions(). No phase file changes needed.Fix
chestItem()now walks the raw map depth first and deserializes any map carrying a==type key throughConfigurationSerializationbefore the item is built, so meta is a realItemMetaby the time Bukkit sees it. The per-item material check and the "skip unknown item, keep the phase" behaviour from 1.26.0 are unchanged.Fails soft: a part that cannot be deserialized is left as a map and logged, so a bad meta section costs its meta rather than the whole item.
Verification
Real Paper 26.2 server, shipped phase files, a probe plugin reading the loaded Plains chests:
No
Skipping itemorCould not readlines in the boot log, so every serialized object across all phases deserialized cleanly.New unit test
testLoadPhasesChestItemKeepsMetaloads a chest file in the shipped shape and asserts the meta section reaches the meta deserializer intact; before the fix it was never called at all. Full suite: 553 tests, 0 failures.Version bumped to 1.26.2.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SAQ3YQkcfRoCZEwa6SPJcp