(add) Option to prevent adding hooks (only is effective if cncp has been
loaded already).
This commit is contained in:
parent
cb1ff7b30b
commit
94015d1066
|
@ -17,15 +17,12 @@ STACK
|
|||
|
||||
? another sequence number (for standard events)
|
||||
|
||||
*** 0.3.0
|
||||
|
||||
!(add) Option to prevent adding hooks by name.
|
||||
!(add) Refactor citizens hook into a general hook using reflection (PlayerClassHook).
|
||||
|
||||
VERSION HISTORY
|
||||
---------------------------
|
||||
|
||||
(0.3.0)
|
||||
- (add) Option to prevent adding hooks (only is effective if cncp has been loaded already).
|
||||
- (add) Generic hook for the Player class name, defaults to exempt all non CraftPlayer classes from checks.
|
||||
- (remove) Direct hooking of Citizens (+direct CraftBukkit dependency).
|
||||
|
||||
|
|
|
@ -99,6 +99,10 @@ public class CompatNoCheatPlus extends JavaPlugin implements Listener {
|
|||
*/
|
||||
public static boolean addHook(Hook hook){
|
||||
if (!enabled) return false;
|
||||
if (Settings.preventAddHooks.contains(hook.getHookName())){
|
||||
System.out.println("[cncp] Prevented adding hook: "+hook.getHookName() + " / " + hook.getHookVersion());
|
||||
return false;
|
||||
}
|
||||
Listener[] listeners = hook.getListeners();
|
||||
if (listeners != null){
|
||||
// attempt to register events:
|
||||
|
|
|
@ -17,6 +17,11 @@ public class Settings {
|
|||
public String playerClassName = "CraftPlayer";
|
||||
public boolean exemptSuperClass = true;
|
||||
|
||||
/**
|
||||
* TODO: I don't like this too much :)
|
||||
*/
|
||||
public static Set<String> preventAddHooks = new HashSet<String>();
|
||||
|
||||
public static CompatConfig getDefaultConfig(){
|
||||
CompatConfig cfg = new NewConfig(null);
|
||||
Settings ref = new Settings();
|
||||
|
@ -26,6 +31,7 @@ public class Settings {
|
|||
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.prevent-add", new LinkedList<String>());
|
||||
return cfg;
|
||||
}
|
||||
|
||||
|
@ -43,6 +49,7 @@ public class Settings {
|
|||
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);
|
||||
ConfigUtil.readStringSetFromList(cfg, "hooks.prevent-add", preventAddHooks, true, true, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue