Adds code for migrating old configuration values

This commit is contained in:
2023-11-16 17:34:37 +01:00
parent 72d33ed7a2
commit ac6fc430ff
3 changed files with 59 additions and 16 deletions

View File

@ -103,18 +103,6 @@ public class GlobalScrapperSettings implements Settings<ScrapperSetting> {
return ConfigHelper.asBoolean(getValue(setting));
}
/**
* Gets the given value as a double
*
* <p>This will throw an exception if used for a non-double setting</p>
*
* @param setting <p>The setting to get the value of</p>
* @return <p>The value of the given setting as a double</p>
*/
public double asDouble(ScrapperSetting setting) {
return ConfigHelper.asDouble(getValue(setting));
}
/**
* Gets the value of a setting, using the default if not set
*
@ -137,12 +125,12 @@ public class GlobalScrapperSettings implements Settings<ScrapperSetting> {
*/
private void loadSettings(DataKey root) {
for (ScrapperSetting setting : ScrapperSetting.values()) {
if (!root.keyExists(setting.getChildPath())) {
if (!root.keyExists(setting.getPath())) {
//If the setting does not exist in the config file, add it
root.setRaw(setting.getChildPath(), setting.getDefaultValue());
root.setRaw(setting.getPath(), setting.getDefaultValue());
} else {
//Set the setting to the value found in the path
settings.put(setting, root.getRaw(setting.getChildPath()));
settings.put(setting, root.getRaw(setting.getPath()));
}
}
}