- (change) Set speed is disabled by default and needs to be anabled by

the config flag.
- (add) Enable flags for the built in generic hooks.
This commit is contained in:
asofold 2012-08-11 13:50:07 +02:00
parent 2cd9c9f0a2
commit 827617eeb6
3 changed files with 29 additions and 8 deletions

View File

@ -25,6 +25,10 @@ STACK
VERSION HISTORY
---------------------------
(5.3.0)
- (change) Set speed is disabled by default and needs to be anabled by the config flag.
- (add) Enable flags for the built in generic hooks.
(5.2.0)
- (add) Add hook to set player speed (simple).

View File

@ -125,6 +125,8 @@ public class CompatNoCheatPlus extends JavaPlugin implements Listener {
* Add standard hooks if available.
*/
private void addAvailableHooks() {
// Set speed
if (settings.setSpeedEnabled){
try{
hookSetSpeed = new me.asofold.bpl.cncp.hooks.generic.HookSetSpeed();
hookSetSpeed.setFlySpeed(settings.flySpeed);
@ -133,11 +135,16 @@ public class CompatNoCheatPlus extends JavaPlugin implements Listener {
addHook(hookSetSpeed);
}
catch (Throwable t){}
}
// Citizens 2
try{
addHook(new me.asofold.bpl.cncp.hooks.citizens2.HookCitizens2());
}
catch (Throwable t){}
// Player class (NPCs, Citizens 1)
if (settings.playerClassEnabled)
addHook(hookPlayerClass);
// mcMMO
try{
addHook(new me.asofold.bpl.cncp.hooks.mcmmo.HookmcMMO());
}

View File

@ -14,10 +14,12 @@ public class Settings {
public Set<String> loadPlugins = new LinkedHashSet<String>();
public Set<String> exemptPlayerClassNames = new HashSet<String>();
public boolean playerClassEnabled = true;
public boolean exemptAllPlayerClassNames = true;
public String playerClassName = "CraftPlayer";
public boolean exemptSuperClass = true;
public boolean setSpeedEnabled = false;
public float flySpeed = 1.0f;
public float walkSpeed = 1.0f;
@ -28,10 +30,12 @@ public class Settings {
Settings ref = new Settings();
cfg.set("plugins.force-enable-later", ConfigUtil.asList(new String[]{ "NoCheatPlus" }));
cfg.set("plugins.ensure-enable", ConfigUtil.asList(new String[]{ "WorldGuard" }));
cfg.set("hooks.player-class.enabled", ref.playerClassEnabled);
cfg.set("hooks.player-class.exempt-names", new LinkedList<String>());
cfg.set("hooks.player-class.exempt-all", ref.exemptAllPlayerClassNames);
cfg.set("hooks.player-class.class-name", ref.playerClassName);
cfg.set("hooks.player-class.super-class", ref.exemptSuperClass);
cfg.set("hooks.set-speed.enabled", ref.setSpeedEnabled);
cfg.set("hooks.set-speed.fly-speed", ref.flySpeed);
cfg.set("hooks.set-speed.walk-speed", ref.walkSpeed);
cfg.set("hooks.prevent-add", new LinkedList<String>());
@ -48,12 +52,18 @@ public class Settings {
ConfigUtil.readStringSetFromList(cfg, "plugins.force-enable-later", forceEnableLater, true, true, false);
ConfigUtil.readStringSetFromList(cfg, "plugins.ensure-enable", loadPlugins, true, true, false);
// Generic player class name hook:
playerClassEnabled = cfg.getBoolean("hooks.player-class.enabled", ref.playerClassEnabled);
ConfigUtil.readStringSetFromList(cfg, "hooks.player-class.exempt-names", exemptPlayerClassNames, true, true, false);
exemptAllPlayerClassNames = cfg.getBoolean("hooks.player-class.exempt-all", ref.exemptAllPlayerClassNames);
playerClassName = cfg.getString("hooks.player-class.class-name", ref.playerClassName);
exemptSuperClass = cfg.getBoolean("hooks.player-class.super-class", ref.exemptSuperClass);
// Set speed hook
setSpeedEnabled = cfg.getBoolean("hooks.set-speed.enabled", ref.setSpeedEnabled);
flySpeed = cfg.getDouble("hooks.set-speed.fly-speed", (double) ref.flySpeed).floatValue();
walkSpeed = cfg.getDouble("hooks.set-speed.walk-speed", (double) ref.walkSpeed).floatValue();
// General
ConfigUtil.readStringSetFromList(cfg, "hooks.prevent-add", preventAddHooks, true, true, false);
return true;
}