Load canonical read-only config.yml and stop automatic writes #2

Merged
NotAlexNoyle merged 1 commits from codex/fix-config-file-reading-and-remove-writing into master 2026-03-24 11:31:48 -04:00
NotAlexNoyle commented 2026-03-24 11:31:08 -04:00 (Migrated from github.com)

Motivation

  • The plugin was reporting many missing options because config reads could come from synthesized/default-backed sources and the code contained paths that attempted to auto-create or modify config state instead of using a single canonical file.
  • The goal is to make config.yml the canonical, read-only source and to fail fast with a clear error if it is missing so users manage the file manually.

Description

  • Added a file-backed canonical configuration in GameModeInventories by introducing canonicalConfig, the loadCanonicalConfig() method, and overriding getConfig() to return the canonical object.
  • Made onEnable() fail early and disable the plugin when the canonical config.yml is not present, with a SEVERE log explaining the read-only policy.
  • Updated GameModeInventoriesConfig.checkConfig() to stop when config.yml is missing and to use plugin.getConfig() (the canonical source) for validation instead of loading or modifying a separate YamlConfiguration instance.
  • Removed direct calls that previously loaded/instantiated a separate YamlConfiguration for the config (so all config reads now come from the same file-backed object).

Testing

  • Ran ./gradlew test, which failed due to the build/toolchain environment raising a Gradle/Kotlin Java version parsing error (IllegalArgumentException: 25.0.1), not due to the plugin code changes.
  • Ran ./gradlew compileJava --stacktrace, which failed with the same Java/Gradle parsing error in this environment, indicating the build system (JDK/Gradle/Kotlin) mismatch rather than functional regressions in the changes.

Codex Task

### Motivation - The plugin was reporting many missing options because config reads could come from synthesized/default-backed sources and the code contained paths that attempted to auto-create or modify config state instead of using a single canonical file. - The goal is to make `config.yml` the canonical, read-only source and to fail fast with a clear error if it is missing so users manage the file manually. ### Description - Added a file-backed canonical configuration in `GameModeInventories` by introducing `canonicalConfig`, the `loadCanonicalConfig()` method, and overriding `getConfig()` to return the canonical object. - Made `onEnable()` fail early and disable the plugin when the canonical `config.yml` is not present, with a `SEVERE` log explaining the read-only policy. - Updated `GameModeInventoriesConfig.checkConfig()` to stop when `config.yml` is missing and to use `plugin.getConfig()` (the canonical source) for validation instead of loading or modifying a separate `YamlConfiguration` instance. - Removed direct calls that previously loaded/instantiated a separate `YamlConfiguration` for the config (so all config reads now come from the same file-backed object). ### Testing - Ran `./gradlew test`, which failed due to the build/toolchain environment raising a Gradle/Kotlin Java version parsing error (`IllegalArgumentException: 25.0.1`), not due to the plugin code changes. - Ran `./gradlew compileJava --stacktrace`, which failed with the same Java/Gradle parsing error in this environment, indicating the build system (JDK/Gradle/Kotlin) mismatch rather than functional regressions in the changes. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69c2ad6172ac832fb71ffa5a446d999f)
Sign in to join this conversation.