ohowe1 / SpectatorModeRewrite

Minecraft plugin that allows players to go into spectator mode but enables admins to prevent features of it.
https://www.spigotmc.org/resources/smp-spectator-mode-1-16-support.77267/
MIT License
17 stars 9 forks source link

No comments in config file #55

Open JCox06 opened 2 years ago

JCox06 commented 2 years ago

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:

  1. 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!

ohowe1 commented 2 years ago

Hi, this is obviously something that would be very useful for everyone. I don't currently have much time to do this myself but if you submitted a pull request I would definitely look at it. I think I recall md5 saying something about making it so comments will always stay in a future update. Thanks.

JCox06 commented 2 years ago

It seems quite challenging to include both functionality. I'll defiantly take a look although I don't know how long it will be until I can get a pull request to you. Thanks.