Config file is rewritten on startup
SlimeDog opened this issue · 18 comments
Spigot 1.12.2
MH 5.5.3
The config.yml file is backed up and rewritten on each server restart. The backup file does not contain the empty messages
message: ''
in fact, the message: lines are missing altogether.
On server restart, the default message are written into the config.yml. Consequently, I edit the config.yml during the startup process, in order to (re)create empty messages.
It is not clear why the file needs to be rewritten by the plugin, rather than just read, and an additional concern that it does not match the backups. (I have not tested whether the latest backup file could be used to replace a (damaged) config.yml.)
I would much prefer that the file was simply parsed, and any errors reported in the console/log.
Spigot 1.12.2
MH 5.5.5
config.yml is still rewritten on startup. On first restart, after update to 5.5.5, the mobs.*.message nodes were missing entirely, not the
message: ''
as I had edited them.
On the next restart the messages were replaced with new ones:
message: You killed a §1{killed}
On the next restart, after I replaced the messages with
message: ''
the messages nodes were missing entirely again.
On the next restart the messages were replaced with new ones:
message: You killed a §1{killed}
This cycle continues, alternating between no message nodes and the new ones.
I do not understand why the file needs to be rewritten. This entire issue would be resolved if it were not. As it is, I configure the plugin the way I want it, only to have the configuration rewritten by the plugin.
If you feel that it is absolutely necessary (say, to help people who cannot be bothered), then please implement a configuration option not to rewrite the configuration file on startup (or any other time). I will add new configuration nodes myself (it would be helpful if the default configuration were supplied in the plugin or on the web site, but I can manage that, as discussed in separate issue).
Any nodes not found in the config.yml should use (published) defaults.
If I remove the line and do /mh reload it doesn't change anything however on 5.5.6.
@Sikatsu This what @slimedogs says "it works now" :-)
Hmm. I added message: "' and did a full server restart since /mh reload didn't work on it. Seems to work for now, but noticed it still changes something in the config since the size changed.
I still see no reason for the file to be rewritten. Just parse it and leave it alone. Send any ERROR or WARN message to the console/log.
The config.yml is not a file in the jar. It is build EVERYTIME, this is why I can update all comments without changing the values. So the config.yml is rewritten everytime I cant change that. Sorry.
Confirmed. In release 5.5.6
message: ''
Will not be removed anymore. I tried to save some lines in the config. I cant both have a default value "You killed ..." and remove empty lines.
You could save a lot of config lines by having a default section at the top. Then only differences from defaults would have to be noted. :)
Something like:
mobs:
default:
enabled: true
message: ''
money:
amount: '50.0'
chance: 1.0
commands:
- chance: '0.0'
cmd: ''
message: ''
head:
drophead: false
chance: 0.0
message: ''
# ### Blaze settings ###
blaze:
money:
amount: '100.0'
# ### Cave Spider settings ###
cave_spider: []
# ### Creeper settings ###
creeper: []
...
This would be easily parsed, and would not have to be rewritten every startup.
I know I could save a lot of code :-)
Normally my config works well. I'm just having troubles with this major change i did. There have been moments where I regret that I started this change :-)
V5.5.6 is released
Thanks for speedy response. I'll check 5.5.6.
IMHO, the complexity contributes to the code and time spent. The config is much simpler than 5.4.x, though, and that is very much appreciated.
Spigot 1.12.2
MH 5.5.6
Confirm that while config.yml is still being rewritten on each startup, the empty messages
message: ''
remain intact. Thank you.
Ha ha :-)
I think it is very use full that I am able to update comments, show me another olugin which can do the same. Normally my config works very well, but the 5.5.0 was a major change, where I had to change my AutoConfig as well, this has been very time consuming, but now I know how to make more improvements.
Anyway the horse is dead starting to chance the config again now woukd be crazy. I need a bit of spare time now, watching some movies ;-)
And there are plenty of good movies to watch. Catch up with the Oscars nominees and winners.
I know. But it doesn't have to be that way, and it is not optimal. Other plugins manage this trick. One of the simplest methods is to provide config.yml in the JAR, and to announce changes to the default configuration file (when appropriate) in the release notes. That lets users decide if they care about updating the comments. Some do (including me -- I'm religious about the config.yml content), others don't.
However, I am going to try not to keep beating this dead horse. :)