mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-11 21:06:55 +00:00
Old config migration
This commit is contained in:
@@ -42,6 +42,10 @@ public class ConfigCache {
|
|||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
config = plugin.getConfig();
|
config = plugin.getConfig();
|
||||||
|
|
||||||
|
migrate("settings.punish_for_combat_logout.enabled",
|
||||||
|
"settings.punish_for_combat_logout.kill",
|
||||||
|
true);
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
this.pvp_enabled_by_default = getBoolean(
|
this.pvp_enabled_by_default = getBoolean(
|
||||||
"settings.pvp_enabled_by_default",
|
"settings.pvp_enabled_by_default",
|
||||||
@@ -238,5 +242,11 @@ public class ConfigCache {
|
|||||||
return getList(path, def, null);
|
return getList(path, def, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void migrate(String oldPath, String newPath, @Nullable Object defaultValue) {
|
||||||
|
if (config.isSet(oldPath) && !config.isSet(newPath)) {
|
||||||
|
Object value = config.get(oldPath);
|
||||||
|
config.set(newPath, value != null ? value : defaultValue);
|
||||||
|
config.set(oldPath, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user