Reset set-speed hook values for older config versions.

Some people might have had the inoperable set-speed hook enabled.
This commit is contained in:
asofold 2013-07-17 11:57:06 +02:00
parent 3103ffbafa
commit c23e39d156
2 changed files with 25 additions and 5 deletions

View File

@ -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 (!).
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

View File

@ -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<String> forceEnableLater = new LinkedHashSet<String>();
public Set<String> loadPlugins = new LinkedHashSet<String>();
@ -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<String>()); // ConfigUtil.asList(new String[]{ "NoCheatPlus" }));
cfg.set("plugins.ensure-enable", ConfigUtil.asList(new String[]{ "WorldGuard" }));
cfg.set("hooks.prevent-add", new LinkedList<String>());
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;
}