mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Improve BadPackets, fix #187/#194
This commit is contained in:
1 parent
9d97803d5c
commit
f32efaedee
6 files changed
+40
-33
No files matched your search
@@ -202,7 +202,8 @@ public class Backend {
|
||||
if (y <= 0.11761 && y >= 0.11759 && !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||
&& !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|
||||
&& !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())
|
||||
&& !Utilities.isNearClimbable(player)) {
|
||||
&& !Utilities.isNearClimbable(player)
|
||||
&& !player.isGliding()) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"tried to climb a non-climbable block (" + player.getLocation().getBlock().getType() + ")");
|
||||
} else {
|
||||
|
||||
@@ -38,14 +38,16 @@ public final class ElytraCheck {
|
||||
public static final HashMap<UUID, Double> JUMP_Y_VALUE = new HashMap<UUID, Double>();
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(Player player, Distance distance) {
|
||||
public static CheckResult runCheck(final Player player, final Distance distance) {
|
||||
// Not relevant
|
||||
if (Utilities.isNearWater(player)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|
||||
|| System.currentTimeMillis() - AntiCheatReloaded.getManager().getUserManager().getUser(uuid)
|
||||
.getMovementManager().lastTeleport <= 500) {
|
||||
// This was a teleport, so skip check.
|
||||
JUMP_Y_VALUE.remove(uuid);
|
||||
return PASS;
|
||||
@@ -56,8 +58,8 @@ public final class ElytraCheck {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
double changeY = distance.toY() - distance.fromY();
|
||||
boolean upwardMovement = changeY > 0;
|
||||
final double changeY = distance.toY() - distance.fromY();
|
||||
final boolean upwardMovement = changeY > 0;
|
||||
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
// Tident added in 1.13
|
||||
if (player.getInventory().getItemInMainHand().getType() == XMaterial.TRIDENT.parseMaterial()) {
|
||||
@@ -68,20 +70,19 @@ public final class ElytraCheck {
|
||||
}
|
||||
}
|
||||
|
||||
if (changeY == 0.0D) {
|
||||
// Seen no false positives here yet
|
||||
return new CheckResult(CheckResult.Result.FAILED, "had no Y-axis dropoff when gliding with Elytra");
|
||||
}
|
||||
|
||||
if (!JUMP_Y_VALUE.containsKey(uuid)) {
|
||||
// Distance + player height
|
||||
JUMP_Y_VALUE.put(uuid, distance.toY() + 1.8D);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
double lastY = JUMP_Y_VALUE.get(uuid);
|
||||
final double lastY = JUMP_Y_VALUE.get(uuid);
|
||||
if (changeY == 0.0D && lastY < 9999.99D) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "had no Y-axis dropoff when gliding with Elytra");
|
||||
}
|
||||
|
||||
if (lastY < distance.toY()) {
|
||||
double diff = distance.toY() - lastY;
|
||||
final double diff = distance.toY() - lastY;
|
||||
if (diff > 0.7675) {
|
||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||
Location to = player.getLocation();
|
||||
|
||||
@@ -114,10 +114,12 @@ public final class FlightCheck {
|
||||
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 1.25, 0))
|
||||
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 0.75, 0))
|
||||
&& (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0))
|
||||
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR))
|
||||
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR)) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirFlight",
|
||||
"tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
|
||||
}
|
||||
|
||||
// TODO falses when falling large distances
|
||||
if (Math.abs(movementManager.motionY
|
||||
- movementManager.lastMotionY) < (movementManager.airTicks >= 115 ? 1E-3 : 5E-3)
|
||||
&& !Utilities.couldBeOnBoat(player)
|
||||
@@ -127,9 +129,10 @@ public final class FlightCheck {
|
||||
&& movementManager.elytraEffectTicks <= 25
|
||||
&& !Utilities.isNearClimbable(distance.getFrom().clone().subtract(0, 0.51D, 0))
|
||||
&& !Utilities.isNearWater(player)
|
||||
&& !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0)))
|
||||
&& !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0))) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff="
|
||||
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
|
||||
}
|
||||
}
|
||||
// End AirFlight
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.packet;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -34,6 +31,7 @@ import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
public final class BadPacketsCheck {
|
||||
|
||||
@@ -69,20 +67,24 @@ public final class BadPacketsCheck {
|
||||
final double z = packet.getDoubles().read(2);
|
||||
final float yaw = packet.getFloat().read(0);
|
||||
// Create location from new data
|
||||
final Location previous = player.getLocation();
|
||||
final Location current = new Location(previous.getWorld(), x, y, z, yaw, pitch);
|
||||
final double distance = previous.distanceSquared(current);
|
||||
double maxDistance = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance");
|
||||
// Fix falling false
|
||||
if (movementManager.airTicks >= 40 && movementManager.motionY < 0 && movementManager.lastMotionY < 0) {
|
||||
maxDistance *= 1.5D;
|
||||
}
|
||||
|
||||
if (distance > maxDistance) {
|
||||
final Location previous = player.getLocation().clone();
|
||||
// Only take horizontal distance
|
||||
previous.setY(0);
|
||||
final Location current = new Location(previous.getWorld(), x, 0, z, yaw, pitch);
|
||||
final double distanceHorizontal = previous.distanceSquared(current);
|
||||
final double distanceVertical = y - player.getLocation().getY();
|
||||
final double maxDistanceHorizontal = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance")
|
||||
+ user.getVelocityTracker().getHorizontal();
|
||||
if (distanceHorizontal > maxDistanceHorizontal) {
|
||||
flag(player, event,
|
||||
"moved too far between packets (distance="
|
||||
+ new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance
|
||||
+ ", at=" + movementManager.airTicks + ")");
|
||||
"moved too far between packets (HT, distance=" + Utilities.roundDouble(distanceHorizontal, 1)
|
||||
+ ", max=" + Utilities.roundDouble(maxDistanceHorizontal, 1) + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
if (distanceVertical < -4.0D && user.getVelocityTracker().getVertical() != 0.0D) {
|
||||
flag(player, event, "moved too far between packets (VT, distance="
|
||||
+ Utilities.roundDouble(Math.abs(distanceVertical), 1) + ", max=4.0)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ public final class PlayerListener extends EventListener {
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
|
||||
@@ -273,7 +273,7 @@ morepackets:
|
||||
# Maximum amount of lag compensation a player can acquire (50ms = 1 tick)
|
||||
minimumClamp: 1250
|
||||
# The amount of milliseconds offset between packets before flagging (50ms = 1 tick)
|
||||
triggerBalance: 200
|
||||
triggerBalance: 250
|
||||
# The amount of milliseconds to compensate for a teleport (50ms = 1 tick)
|
||||
teleportCompensation: 500
|
||||
# Should this check be disabled for 'lagging' players?
|
||||
|
||||
Reference in new issue
Block a user