From c23e39d156285e5654c05d455ecfe5fea7993fc9 Mon Sep 17 00:00:00 2001 From: asofold Date: Wed, 17 Jul 2013 11:57:06 +0200 Subject: [PATCH] Reset set-speed hook values for older config versions. Some people might have had the inoperable set-speed hook enabled. --- CompatNoCheatPlus/cncp_lists.txt | 5 +++- .../me/asofold/bpl/cncp/config/Settings.java | 25 ++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CompatNoCheatPlus/cncp_lists.txt b/CompatNoCheatPlus/cncp_lists.txt index 707f31a..4e4235e 100644 --- a/CompatNoCheatPlus/cncp_lists.txt +++ b/CompatNoCheatPlus/cncp_lists.txt @@ -66,4 +66,7 @@ support for instant spells ? [internalName or name ? <- guess: name] ? add info command: show all hooks and so on. -add class-name inspection methods (!). \ No newline at end of file +add class-name inspection methods (!). + +set-speed: per world options ? [per world config concept] +set-speed: add option to set speed to default speed on player quit/kick diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/config/Settings.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/config/Settings.java index fbde62a..c0da7dd 100644 --- a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/config/Settings.java +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/config/Settings.java @@ -5,12 +5,14 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.Set; +import org.bukkit.Bukkit; + import me.asofold.bpl.cncp.config.compatlayer.CompatConfig; import me.asofold.bpl.cncp.config.compatlayer.ConfigUtil; import me.asofold.bpl.cncp.config.compatlayer.NewConfig; public class Settings { - public int configVersion = 1; + public static final int configVersion = 2; public Set forceEnableLater = new LinkedHashSet(); public Set loadPlugins = new LinkedHashSet(); @@ -19,11 +21,10 @@ public class Settings { public static CompatConfig getDefaultConfig(){ CompatConfig cfg = new NewConfig(null); - Settings ref = new Settings(); cfg.set("plugins.force-enable-later", new LinkedList()); // ConfigUtil.asList(new String[]{ "NoCheatPlus" })); cfg.set("plugins.ensure-enable", ConfigUtil.asList(new String[]{ "WorldGuard" })); cfg.set("hooks.prevent-add", new LinkedList()); - cfg.set("configversion", ref.configVersion); + cfg.set("configversion", configVersion); return cfg; } @@ -31,10 +32,26 @@ public class Settings { boolean changed = false; if (cfg.getInt("configversion", 0) == 0){ cfg.remove("plugins"); - cfg.set("configversion", new Settings().configVersion); // hum. + cfg.set("configversion", configVersion); changed = true; } + if (cfg.getInt("configversion", 0) <= 1){ + if (cfg.getDouble("hooks.set-speed.fly-speed", 0.1) != 0.1){ + changed = true; + cfg.set("hooks.set-speed.fly-speed", 0.1); + Bukkit.getLogger().warning("[cncp] Reset fly-speed for the set-speed hook to 0.1 (default) as a safety measure."); + } + if (cfg.getDouble("hooks.set-speed.walk-speed", 0.2) != 0.2){ + changed = true; + cfg.set("hooks.set-speed.walk-speed", 0.2); + Bukkit.getLogger().warning("[cncp] Reset walk-speed for the set-speed hook to 0.2 (default) as a safety measure."); + } + } if (ConfigUtil.forceDefaults(getDefaultConfig(), cfg)) changed = true; + if (cfg.getInt("configversion", 0) != configVersion){ + cfg.set("configversion", configVersion); + changed = true; + } return changed; }