From c1d0fcf5b380c910c2f7c769c41fa8eb6c3972f5 Mon Sep 17 00:00:00 2001 From: ElFrod0 Date: Wed, 14 May 2025 02:02:51 +0200 Subject: [PATCH] Old config migration --- .../preventstabby/config/ConfigCache.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/youhavetrouble/preventstabby/config/ConfigCache.java b/src/main/java/me/youhavetrouble/preventstabby/config/ConfigCache.java index 9448c8f..cca1ca4 100644 --- a/src/main/java/me/youhavetrouble/preventstabby/config/ConfigCache.java +++ b/src/main/java/me/youhavetrouble/preventstabby/config/ConfigCache.java @@ -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); + } + } }