Leaf Config refactor - #877
Draft
Dreeam-qwq wants to merge 18 commits into
Draft
Conversation
Member
Author
|
For now, only the config framework is complete. The actual Leaf config module refactor and Gale migration mappings will be added later. There are some TODOs, can be ignored during the review:
|
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.
Global config refactor
Refactored the Leaf config framework with clearer naming and improved scalability for the newly introduced world config impl.
The config module design is based on Luminol's config design and introduces two annotations:
@DoNotLoad— Marks non-config option fields that are assigned from config values at runtime.@HotReloadUnsupported— Marks options whose values must not change during config reloads.Example global config module class:
World config
Implemented Leaf world config.
Unlike Paper, Leaf does not automatically generate an empty config file in every world directory. This keeps world directories clean (user-friendly!). The overridden world config has any effect only when the user manually creates a
leaf-world.ymlfile and adds the desired options.The world config module is also per-file config similar to Leaf global config, and correspond field is provided in
LeafWorldConfigfor easy access.Example world config module class:
Config migration
Leaf general config migration
The general Leafconfig migration is for migrating the option config if config paths have changed.
The migration is based on the
config-versionand supports:So, users no longer need to manually update values when config paths are renamed.
Gale config migration
The Gale config has been removed, and all existing Gale options have been moved into Leaf modules.
A migration process is provided to preserve existing changed values.
Migration steps:
gale-world.ymltoleaf-world.ymlunder each dimension directory when each level is loaded. (Config files under unloaded levels will be ignored)config/backup<timestamp>/directory after the migration.gale-global.ymlgale-world-deault.ymlgale-world.ymlunder each loaded dimension directoryNote: Gale world override config migration is skipped if
leaf-world.ymlalready exists,gale-world.ymlcontains malformed config, or other errors occur. The step 3 and 4 will still run. Here, I assume the Gale config can load sucessfully before.Fixes
Fixed missing comments on reloading config