Repository navigation
Fix /pixelchat reload not applying config changes (API key, log level, language, ChatGuard state) - #9
Conversation
Agent-Logs-Url: https://github.com/PixelMindMC/PixelChatGuardian/sessions/ab9087c2-485b-4c49-8040-6292f52e9084 Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
/pixelchat reload not applying config changes (API key, log level, language, ChatGuard state)
| this.loggingHelper = plugin.getLoggingHelper(); | ||
| this.configHelper = plugin.getConfigHelper(); | ||
| this.configHelperPlayerStrikes = plugin.getConfigHelperPlayerStrikes(); | ||
| this.configHelperLanguage = plugin.getConfigHelperLanguage(); |
There was a problem hiding this comment.
Why did you remove the variable and get the ConfigHelper from the plugin every single time?
There was a problem hiding this comment.
@copilot Explore whether another pattern is more fitting here, and apply it to the other changed files as well. Using the getter every single time isn't ideal and quite verbose
There was a problem hiding this comment.
Applied in commit dedaef1. Instead of removing the field and scattering plugin.getConfigHelperLanguage() calls throughout each method, each method that needs the language config now resolves it once into a local variable at the top (ConfigHelper configHelperLanguage = plugin.getConfigHelperLanguage()). This keeps the code as readable as a field reference while ensuring it always picks up the current language setting after a reload.
# Conflicts: # src/main/java/de/pixelmindmc/pixelchat/commands/PixelChatCommand.java
…instead of inline getter calls Agent-Logs-Url: https://github.com/PixelMindMC/PixelChatGuardian/sessions/54e9aa28-56d1-4d25-8493-a6fcf24c8704 Co-authored-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
APIHelper.java: remove cached config fields; read fromconfigHelperdynamically on each callPixelChat.java: addreloadPlugin()that reloads all 12 configs, updates log level, and re-initializesAPIHelper/ChatGuardHelperPixelChatCommand.java: delegate reload toplugin.reloadPlugin(); resolve languageConfigHelperas a local variable at the start of each method instead of callingplugin.getConfigHelperLanguage()inline on every usageChatGuardHelper.java: resolve languageConfigHelperas a local variable at the start of each method (same pattern)AsyncPlayerChatListener.java: checkplugin.getAPIHelper() != nulldynamically per event instead of a cached boolean