fix: New keyed types did not survive a save/load cycle.#101
Merged
svaningelgem merged 10 commits intomasterfrom Dec 15, 2025
Merged
fix: New keyed types did not survive a save/load cycle.#101svaningelgem merged 10 commits intomasterfrom
svaningelgem merged 10 commits intomasterfrom
Conversation
- Extended getStaticFieldName to check interface constants - Added recursive checkInterfaceFields method to traverse interface hierarchy - Added testInterfaceElement test case to verify interface field detection - Fixes issue where interface constants were not properly detected
- Removed GENERIC_TOSTRING_PATTERN check condition - Always attempt to find static field name (class or interface) - Removed unused Pattern and Matcher imports - Minimal change to support custom toString() methods
- Added declaredType field to NestedNode to track field's declared type - Pass field type through YamlWriter chain (writeValue -> writeScalar -> formatValue) - Extended getStaticFieldName to accept declaredType parameter - Added searchByDeclaredType method (incomplete - needs clarification) Note: Current implementation incomplete - StaticMat doesn't implement StaticInterfaceElements, so checking declared type's interfaces won't find the constants. Need clarification on approach.
- Added WeakHashMap registry to track static field instances and their sources - Register static fields when loaded via getFieldValue - Check registry first in getStaticFieldName before searching - Register fields lazily during searchByDeclaredType - Minimal solution: tracks "original type" during construction/load as suggested
- Register static field sources during loadFields, BEFORE YAML overwrites them - Scan field values at their initialized state (e.g., StaticInterfaceElements.A) - Search package for common interface naming patterns - Registry now captures values at construction/load time, not during save - This correctly implements "tracking during load" as suggested
Registration now only happens during load phase, not during field lookup
- Register in buildYamlContents before serialization - Handles first save before any load has occurred - Discovers StaticInterfaceElements from StaticMat field type - Now works for both save-first and load-first scenarios
Completely scratch the registry/tracking approach. Now simply: - Check if value implements org.bukkit.Keyed (via reflection) - Call getKey().getKey() to get the key string - Replace dots with underscores - Much simpler solution for Bukkit/Spigot integration
|
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
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.



No description provided.