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