Skip to content

refactor: Rewrite config using Night-Config (TOML)#9

Open
ZephByte wants to merge 6 commits into
mainfrom
config-updates
Open

refactor: Rewrite config using Night-Config (TOML)#9
ZephByte wants to merge 6 commits into
mainfrom
config-updates

Conversation

@ZephByte

@ZephByte ZephByte commented Oct 7, 2025

Copy link
Copy Markdown
Owner

This MR completely overhauls the mod's configuration system by replacing the manual .properties file implementation with the powerful Night-Config library, using the TOML format.

This change significantly improves the maintainability, readability, and robustness of the configuration management.

Key Changes

  • Switched to Night-Config:

    • Added the com.electronwill.night-config:toml dependency.
    • Configuration is now stored in config/ScaledDragonFight.toml, which is more structured and user-friendly than a properties file.
  • Complete ConfigManager.kt Rewrite:

    • The old ConfigManager object, which was responsible for manual file I/O, parsing, and default value handling, has been replaced with a modern, type-safe, and declarative system.
    • A new public API, SDFConfig, provides structured, read-only access to all configuration values (e.g., SDFConfig.healthScaling.baseDragonHealth).
    • Configuration properties are now grouped into logical categories (general, healthScaling, spawnDelay, etc.) for better organization.
    • A property delegate helper (define) is used to reduce boilerplate, automatically handle default values, and generate comments in the config file.
  • Codebase-wide Refactoring:

    • All parts of the mod that previously accessed ConfigManager have been updated to use the new SDFConfig object. This includes DragonScaler, DragonEventHandler, and ModCommands.
  • New Configuration Options:

    • Added new (currently unused) options to control the countdown visibility in the Overworld, Nether, and The End, providing more granular control for server admins.

Benefits of this Change

  • Improved User Experience: The TOML format is easier for server owners to read and edit. The auto-generated comments provide clear guidance.
  • Increased Robustness: Night-Config handles file loading, parsing, and saving, which is less error-prone than the previous manual implementation. It gracefully handles missing values by applying defaults.
  • Better Developer Experience: Adding new configuration options is now trivial and requires minimal boilerplate. The code is cleaner, more organized, and type-safe.
  • Future-Proofing: The new structure is easily extensible for future features.

@ZephByte ZephByte self-assigned this Oct 7, 2025
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.

1 participant