Old config migration

This commit is contained in:
ElFrod0
2025-05-14 02:02:51 +02:00
parent b3d9ae720f
commit c1d0fcf5b3
@@ -42,6 +42,10 @@ public class ConfigCache {
plugin.reloadConfig();
config = plugin.getConfig();
migrate("settings.punish_for_combat_logout.enabled",
"settings.punish_for_combat_logout.kill",
true);
// Settings
this.pvp_enabled_by_default = getBoolean(
"settings.pvp_enabled_by_default",
@@ -238,5 +242,11 @@ public class ConfigCache {
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);
}
}
}