SpectatorModeRewrite
SpectatorModeRewrite copied to clipboard
No comments in config file
Describe the bug The config.yml comments are discarded when the file is exported into the plugin's directory folder. This makes it harder to understand the config parameters.
To Reproduce Steps to reproduce the behavior:
- Install plugin for first time and check config.yml
Minecraft version 1.17.1
Expected behavior That the config file contains information about the settings for the plugin.
Additional context This appears to be an issue in the config manager when calling JavaPlugin#saveConfig(). Calling JavaPlugin#saveDefaultConfig() instead will export the whole file if it is not already there including comments. However, in the constructor of ConfigManager, removing the range based for loop and replacing it with JavaPlugin#setDefaultConfig() will mean when the plugin updates, missing keys will not be added to the config file. So I suppose it depends on what functionality you want in the plugin. I don't think there is a way to allow both as updating the config will remove all comments. I wonder if there is a way to preserve comments while still updating the configuration file. If this is something you want changing I don't mind working on the Pull Request.
Thank you!