Migrate old configs to newest version automatically#7
Migrate old configs to newest version automatically#7
Conversation
…0 configs) Agent-Logs-Url: https://github.com/PixelMindMC/PixelChatGuardian/sessions/c926d3ab-a619-48c5-9ae1-12df63aa4995 Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
|
@copilot So does this only apply for upgraded configs from 1.2.0 -> current? If so, do you think this is the best way to tackle this seemingly architectural problem, or should the way this stuff is handled change altogether? Or should there simply be a disclaimer in the changelog of 1.3.0 to make sure the config is changed or made to regenerate, and then changed appropriately? Pick what you think is best here and go ahead. |
Agent-Logs-Url: https://github.com/PixelMindMC/PixelChatGuardian/sessions/94732aa5-7c3d-44c3-a32d-4931a61108d8 Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
The Went with proper config migration instead (commit
The |
ToothyDev
left a comment
There was a problem hiding this comment.
Also add this as a changelog entry for 1.3.0 since this is a noteworthy addition
Agent-Logs-Url: https://github.com/PixelMindMC/PixelChatGuardian/sessions/64635998-1821-43d3-9c4f-87238abef58c Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Added in
|
The 1.2.0→current refactor changed the notify config key from the flat
chatguard.notify-userto the nestedchatguard.notify.user. SincesaveDefaultConfig()never overwrites an existing file, upgraded installs retained the old key. Bukkit'sgetBoolean()returnsfalsefor missing keys, silently suppressing all player notifications. Console logs were unaffected because that code path is unconditional.Changes
ConfigHelper: AddedgetBoolean(path, defaultValue)overload delegating to Bukkit'sFileConfiguration.getBoolean(path, def).PixelChat: AddedmigrateConfig()called on startup that automatically migrates old config keys to the current format:chatguard.notify-userflat key, reads its actual value (preserving an explicitfalse), writes it tochatguard.notify.user, and removes the old key.chatguard.notify.admins: trueas the default for the new key when absent from old configs."Configuration migrated to the <version> format."(version read dynamically from the plugin descriptor) when any change is made.CHANGELOG.md: Added a 1.3.0 entry noting automatic config migration for upgraded installs.This approach correctly handles users who had explicitly set
notify-user: falsein their 1.2.0 config, and sets a reusable pattern for future config restructuring.