mirror of
https://github.com/asofold/CompatNoCheatPlus.git
synced 2025-01-20 21:11:43 +01:00
Quick try: Add EntityDamageByEntity hook (aiming at CrackShot).
This commit is contained in:
parent
d910a01aa9
commit
2dea2695b9
@ -15,6 +15,7 @@ import me.asofold.bpl.cncp.hooks.Hook;
|
||||
import me.asofold.bpl.cncp.hooks.generic.ConfigurableHook;
|
||||
import me.asofold.bpl.cncp.hooks.generic.HookBlockBreak;
|
||||
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.utils.TickTask2;
|
||||
@ -190,6 +191,7 @@ public class CompatNoCheatPlus extends JavaPlugin implements Listener {
|
||||
new HookBlockBreak(),
|
||||
new HookBlockPlace(),
|
||||
new HookInstaBreak(),
|
||||
new HookEntityDamageByEntity(),
|
||||
}){
|
||||
builtinHooks.add(hook);
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
package me.asofold.bpl.cncp.hooks.generic;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import me.asofold.bpl.cncp.config.compatlayer.CompatConfig;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
|
||||
public class HookEntityDamageByEntity extends ClassExemptionHook implements
|
||||
Listener {
|
||||
|
||||
public HookEntityDamageByEntity() {
|
||||
super("entity-damage-by-entity.");
|
||||
defaultClasses.addAll(Arrays.asList(new String[] {
|
||||
// CrackShot
|
||||
"WeaponDamageEntityEvent", }));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return "EntityDamageByEntity(default)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookVersion() {
|
||||
return "0.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 onDamageLowest(final EntityDamageByEntityEvent event) {
|
||||
final Entity damager = event.getDamager();
|
||||
if (damager instanceof Player) {
|
||||
checkExempt((Player) damager, event.getClass(), CheckType.FIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
final void onDamageMonitor(final EntityDamageByEntityEvent event) {
|
||||
final Entity damager = event.getDamager();
|
||||
if (damager instanceof Player) {
|
||||
checkUnexempt((Player) damager, event.getClass(), CheckType.FIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user