mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Basic Glide check (i hope it works) thanks to @m1enkrafftman
This commit is contained in:
1 parent
4a596bb158
commit
831b82ff30
3 files changed
+43
-2
No files matched your search
@@ -38,6 +38,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.GlideCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.WaterWalkCheck;
|
||||
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck;
|
||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||
@@ -164,6 +165,8 @@ public class Backend {
|
||||
inventoryTime.remove(pN);
|
||||
inventoryClicks.remove(pN);
|
||||
lastFallPacket.remove(pN);
|
||||
GlideCheck.lastYDelta.remove(pN);
|
||||
GlideCheck.glideBuffer.remove(pN);
|
||||
}
|
||||
|
||||
public CheckResult checkFastBow(Player player, float force) {
|
||||
@@ -860,6 +863,8 @@ public class Backend {
|
||||
YAxisCheck.yAxisLastViolation.remove(player.getName());
|
||||
YAxisCheck.lastYcoord.remove(player.getName());
|
||||
YAxisCheck.lastYtime.remove(player.getName());
|
||||
GlideCheck.lastYDelta.remove(player.getName());
|
||||
GlideCheck.glideBuffer.remove(player.getName());
|
||||
}
|
||||
|
||||
public void logExitFly(final Player player) {
|
||||
|
||||
@@ -3,11 +3,14 @@ package net.gravitydevelopment.anticheat.check.movement;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||
import net.gravitydevelopment.anticheat.check.CheckResult;
|
||||
import net.gravitydevelopment.anticheat.util.Distance;
|
||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -17,9 +20,42 @@ public class GlideCheck {
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static Map<String, Double> lastYDelta = new HashMap<String, Double>();
|
||||
public static Map<String, Integer> glideBuffer = new HashMap<String, Integer>();
|
||||
|
||||
public static CheckResult runCheck(Player player, Distance distance) {
|
||||
String name = player.getName();
|
||||
if(!glideBuffer.containsKey(name))
|
||||
{
|
||||
glideBuffer.put(name, 0);
|
||||
}
|
||||
if(!lastYDelta.containsKey(name))
|
||||
{
|
||||
lastYDelta.put(name, 0.0);
|
||||
}
|
||||
double currentY = player.getLocation().getY();
|
||||
double math = currentY - YAxisCheck.lastYcoord.get(name);
|
||||
if(math < 0 && !AntiCheat.getManager().getBackend().isMovingExempt(player))
|
||||
{
|
||||
if(math <= lastYDelta.get(name) && !(player.getEyeLocation().getBlock().getType() == Material.LADDER)
|
||||
&& !Utilities.isInWater(player) && !Utilities.isInWeb(player)
|
||||
&& Utilities.cantStandAt(player.getLocation().getBlock()))
|
||||
{
|
||||
int currentBuffer = glideBuffer.get(name);
|
||||
glideBuffer.put(name, currentBuffer + 1);
|
||||
if((currentBuffer + 1) >= AntiCheat.getManager().getBackend().getMagic().FLIGHT_LIMIT())
|
||||
{
|
||||
if(!AntiCheat.getManager().getBackend().silentMode())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Glide/Fly hacking detected.");
|
||||
}
|
||||
lastYDelta.put(name, math);
|
||||
return new CheckResult(CheckResult.Result.FAILED, name + " attempted to fall too slowly!");
|
||||
}
|
||||
}
|
||||
}
|
||||
lastYDelta.put(name, math);
|
||||
return PASS;
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class YAxisCheck {
|
||||
if (distance.getYDifference() > AntiCheat.getManager().getBackend().getMagic().TELEPORT_MIN() || distance.getYDifference() < 0) {
|
||||
return PASS;
|
||||
}
|
||||
if (!FlightCheck.isMovingExempt(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && !Utilities.isClimbableBlock(player.getLocation().add(0, -1, 0).getBlock()) && !player.isInsideVehicle() && !Utilities.isInWater(player) && !hasJumpPotion(player) && !isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock())) {
|
||||
if (!FlightCheck.isMovingExempt(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && !Utilities.isClimbableBlock(player.getLocation().add(0, -1, 0).getBlock()) && !player.isInsideVehicle() && !Utilities.isInWater(player) && !hasJumpPotion(player) && !isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock()) && !isMoveUpBlock(player.getLocation().add(0, -1.5, 0).getBlock())) {
|
||||
double y1 = player.getLocation().getY();
|
||||
String name = player.getName();
|
||||
// Fix Y axis spam.
|
||||
|
||||
Reference in new issue
Block a user