I’m testing the loading, modification, and saving of .conf files. So far, it looks like my plugin is overwriting any changes i make to the .conf file, and I’m not sure where this is happening.
Here’s how I load it, with the createConfigs() method
The ‘notgranite’ block state is never added to the blockStateList in the GlobalDefaults object, and the modified .conf file is overwritten. What gives?
At no point in your code that you’ve given us have you actually loaded your config file. On pre-init, you create the defaults, put them into an empty node and save those with no regard to the file on disc.
What I think you want to do is load the configs, merge the defaults into your file, then save the outcome.
I think you want something like this (from memory, may need tweaking).
Note that this is one way of doing it, I’m sure there are others that would do it a different way.
Do bear in mind that if Sponge can’t load the config, it will throw a wobbly. You may want to figure out how to handle configuration errors gracefully - exercise for the reader!
This isn’t relevant to this specific problem (he’s just wanting to give the item a name in metadata, I believe, and therefore has no bearing on this).
and confirmed that the defaults variable was indeed loading my changed config files.
However, there seems to be an issue with the dependency management via the guice injectors. It seems rather than binding my edited config from file it is calling the Defaults Constructor, then returning a new instance. Not sure if this is an appropriate addendum to this thread or if I should make a new one.
ALSO not sure exactly how much code I should throw down here. What would you suggest?