mirror of
https://github.com/asofold/CompatNoCheatPlus.git
synced 2024-11-27 12:45:18 +01:00
Added class based exemption hook for PlayerInteractEvent.
Default contains MagicSpells's wrapped event class.
This commit is contained in:
parent
fe67703311
commit
a490a718c8
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user