mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 06:28:52 +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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user