mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Added Velocity check
This commit is contained in:
1 parent
1696ba6ac1
commit
5f5153e788
7 files changed
+63
-10
No files matched your search
@@ -38,6 +38,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
|
||||
import net.gravitydevelopment.anticheat.check.combat.VelocityCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.BlinkCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.GlideCheck;
|
||||
@@ -118,6 +119,7 @@ public class Backend {
|
||||
public void garbageClean(Player player) {
|
||||
String pN = player.getName();
|
||||
|
||||
VelocityCheck.cleanPlayer(player);
|
||||
KillAuraCheck.cleanPlayer(player);
|
||||
BlinkCheck.MOVE_COUNT.remove(player.getUniqueId());
|
||||
blocksDropped.remove(pN);
|
||||
|
||||
@@ -59,7 +59,8 @@ public enum CheckType {
|
||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
||||
AUTOTOOL(Permission.CHECK_AUTOTOOL),
|
||||
KILLAURA(Permission.CHECK_KILLAURA),
|
||||
BLINK(Permission.CHECK_BLINK);
|
||||
BLINK(Permission.CHECK_BLINK),
|
||||
VELOCITY(Permission.VELOCITY);
|
||||
|
||||
private final Permission permission;
|
||||
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package net.gravitydevelopment.anticheat.check.combat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
||||
import net.gravitydevelopment.anticheat.event.EventListener;
|
||||
|
||||
public class VelocityCheck {
|
||||
|
||||
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
|
||||
|
||||
public static void cleanPlayer(Player p) {
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
}
|
||||
|
||||
public static void runCheck(EntityDamageByEntityEvent e, final Player p) {
|
||||
if (AntiCheat.getManager().getCheckManager().isOpExempt(p) || AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.VELOCITY))
|
||||
return;
|
||||
final Location then = p.getLocation();
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (then.distance(p.getLocation()) < 0.125) {
|
||||
if (!VL_COUNT.containsKey(p.getUniqueId()))
|
||||
VL_COUNT.put(p.getUniqueId(), 1);
|
||||
else {
|
||||
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
|
||||
if (VL_COUNT.get(p.getUniqueId()) > AntiCheat.getManager().getBackend().getMagic().VELOCITY_AMT()) {
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Velocity, had zero/low velocity " + VL_COUNT.get(p.getUniqueId()) + " times (max=" + AntiCheat.getManager().getBackend().getMagic().VELOCITY_AMT() + ")").getMessage(), p, CheckType.VELOCITY);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
}
|
||||
}
|
||||
}.runTaskLater(AntiCheat.getPlugin(), 4);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -381,4 +381,8 @@ public interface Magic {
|
||||
* Maximum amount of packets a player can send in a second; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int BLINK_PACKET();
|
||||
/**
|
||||
* Maximum amount of low/zero velocity before flagging; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int VELOCITY_AMT();
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
@@ -35,6 +36,7 @@ import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
||||
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
|
||||
import net.gravitydevelopment.anticheat.check.combat.VelocityCheck;
|
||||
import net.gravitydevelopment.anticheat.util.Distance;
|
||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||
|
||||
@@ -96,7 +98,7 @@ public class EntityListener extends EventListener {
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
boolean noHack = true;
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
@@ -106,13 +108,7 @@ public class EntityListener extends EventListener {
|
||||
}
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
// Keep players from shooting an arrow at themselves in order to fly
|
||||
if (e.getDamager() instanceof Arrow) {
|
||||
Arrow arrow = (Arrow) e.getDamager();
|
||||
if (arrow.getShooter() instanceof Player && event.getEntity() == arrow.getShooter()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
VelocityCheck.runCheck(e, player);
|
||||
if (Utilities.hasArmorEnchantment(player, Enchantment.THORNS)) {
|
||||
getBackend().logAnimation(player);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public enum Permission {
|
||||
SYSTEM_CALIBRATE,
|
||||
SYSTEM_CHECK,
|
||||
SYSTEM_DEBUG,
|
||||
SYSTEM_RELOAD, CHECK_KILLAURA, CHECK_BLINK;
|
||||
SYSTEM_RELOAD, CHECK_KILLAURA, CHECK_BLINK, VELOCITY;
|
||||
|
||||
private static final String PERMISSION_ALL = "anticheat.*";
|
||||
private static final String PERMISSION_SPAM = "anticheat.check.spam";
|
||||
|
||||
Reference in new issue
Block a user