From fe67703311121d3209124195aca43b90b26bd518 Mon Sep 17 00:00:00 2001 From: TheComputerGeek2 Date: Sat, 3 Dec 2016 17:58:56 -0800 Subject: [PATCH 1/2] Added MagicSpells events to existing class based exemption hooks. - BlockBreak - BlockPlace - EntityDamageByEntity --- .../src/me/asofold/bpl/cncp/hooks/generic/HookBlockBreak.java | 2 ++ .../src/me/asofold/bpl/cncp/hooks/generic/HookBlockPlace.java | 4 +++- .../bpl/cncp/hooks/generic/HookEntityDamageByEntity.java | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookBlockBreak.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookBlockBreak.java index 7f5246e..41fa045 100644 --- a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookBlockBreak.java +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookBlockBreak.java @@ -25,6 +25,8 @@ public class HookBlockBreak extends ClassExemptionHook implements Listener { "ArtificialBlockBreakEvent", // mcMMO "FakeBlockBreakEvent", + // MagicSpells + "MagicSpellsBlockBreakEvent" })); } diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookBlockPlace.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookBlockPlace.java index 9280fa2..1e2870c 100644 --- a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookBlockPlace.java +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookBlockPlace.java @@ -22,7 +22,9 @@ public class HookBlockPlace extends ClassExemptionHook implements Listener{ super("block-place."); defaultClasses.addAll(Arrays.asList(new String[]{ // MachinaCraft - "ArtificialBlockPlaceEvent" + "ArtificialBlockPlaceEvent", + // MagicSpells + "MagicSpellsBlockPlaceEvent" })); } diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookEntityDamageByEntity.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookEntityDamageByEntity.java index 412d888..f5ba3fd 100644 --- a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookEntityDamageByEntity.java +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookEntityDamageByEntity.java @@ -20,7 +20,9 @@ public class HookEntityDamageByEntity extends ClassExemptionHook implements super("entity-damage-by-entity."); defaultClasses.addAll(Arrays.asList(new String[] { // CrackShot - "WeaponDamageEntityEvent", })); + "WeaponDamageEntityEvent", + // MagicSpells + "MagicSpellsEntityDamageByEntityEvent" })); } @Override From a490a718c8e14871c8aca44f6b5b216b80582d1a Mon Sep 17 00:00:00 2001 From: TheComputerGeek2 Date: Sat, 3 Dec 2016 18:50:15 -0800 Subject: [PATCH 2/2] Added class based exemption hook for PlayerInteractEvent. Default contains MagicSpells's wrapped event class. --- .../asofold/bpl/cncp/CompatNoCheatPlus.java | 2 + .../hooks/generic/HookPlayerInteract.java | 58 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookPlayerInteract.java diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/CompatNoCheatPlus.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/CompatNoCheatPlus.java index cfdc6b3..8fb7855 100644 --- a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/CompatNoCheatPlus.java +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/CompatNoCheatPlus.java @@ -19,6 +19,7 @@ import me.asofold.bpl.cncp.hooks.generic.HookBlockPlace; import me.asofold.bpl.cncp.hooks.generic.HookEntityDamageByEntity; import me.asofold.bpl.cncp.hooks.generic.HookInstaBreak; import me.asofold.bpl.cncp.hooks.generic.HookPlayerClass; +import me.asofold.bpl.cncp.hooks.generic.HookPlayerInteract; import me.asofold.bpl.cncp.utils.TickTask2; import me.asofold.bpl.cncp.utils.Utils; @@ -194,6 +195,7 @@ public class CompatNoCheatPlus extends JavaPlugin implements Listener { new HookBlockPlace(), new HookInstaBreak(), new HookEntityDamageByEntity(), + new HookPlayerInteract() }){ builtinHooks.add(hook); } diff --git a/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookPlayerInteract.java b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookPlayerInteract.java new file mode 100644 index 0000000..b9ebc73 --- /dev/null +++ b/CompatNoCheatPlus/src/me/asofold/bpl/cncp/hooks/generic/HookPlayerInteract.java @@ -0,0 +1,58 @@ +package me.asofold.bpl.cncp.hooks.generic; + +import fr.neatmonster.nocheatplus.checks.CheckType; +import me.asofold.bpl.cncp.config.compatlayer.CompatConfig; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; + +import java.util.Arrays; + +/** + * Wrap player interact events to exempt players from checks by comparison of event class names. + * Uses mc_dev's format for exemption based upon class names. + * + */ +public class HookPlayerInteract extends ClassExemptionHook implements Listener{ + + public HookPlayerInteract() { + super("player-interact."); + defaultClasses.addAll(Arrays.asList(new String[]{ + // MagicSpells + "MagicSpellsPlayerInteractEvent" + })); + } + + @Override + public String getHookName() { + return "Interact(default)"; + } + + @Override + public String getHookVersion() { + return "1.0"; + } + + @Override + public Listener[] getListeners() { + return new Listener[]{this}; + } + + @Override + public void applyConfig(CompatConfig cfg, String prefix) { + super.applyConfig(cfg, prefix); + if (classes.isEmpty()) enabled = false; + } + + @EventHandler(priority = EventPriority.LOWEST) + final void onPlayerInteractLowest(final PlayerInteractEvent event){ + checkExempt(event.getPlayer(), event.getClass(), CheckType.BLOCKINTERACT); + } + + @EventHandler(priority = EventPriority.MONITOR) + final void onPlayerInteractMonitor(final PlayerInteractEvent event){ + checkUnexempt(event.getPlayer(), event.getClass(), CheckType.BLOCKINTERACT); + } + +}