diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java b/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java index 963d8f7..723875f 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java @@ -62,7 +62,8 @@ public enum CheckType { CHAT_UNICODE(Permission.CHECK_UNICODE, "ChatUnicode"), ILLEGAL_INTERACT(Permission.CHECK_ILLEGALINTERACT, "IllegalInteract"), FASTLADDER(Permission.CHECK_FASTLADDER, "FastLadder"), - AIMBOT(Permission.CHECK_AIMBOT, "Aimbot"); + AIMBOT(Permission.CHECK_AIMBOT, "Aimbot"), + STRAFE(Permission.CHECK_STRAFE, "Strafe"); private final Permission permission; private final String displayName; diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java index 796a3c1..5d83d66 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java @@ -63,9 +63,7 @@ public class FlightCheck { Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement - || Utilities.isClimbableBlock(distance.getFrom().getBlock()) - || Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)) - || Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.UP))) + || Utilities.isNearClimbable(player)) return PASS; int minAirTicks = 13; @@ -124,7 +122,8 @@ public class FlightCheck { && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")) && (!Utilities.isNearBed(distance.getTo()) - || (Utilities.isNearBed(distance.getTo()) && movementManager.motionY > 0.12675))) + || (Utilities.isNearBed(distance.getTo()) && movementManager.motionY > 0.12675)) + && movementManager.slimeInfluenceTicks == 0) return new CheckResult(CheckResult.Result.FAILED, "tried to climb air (mY=" + movementManager.motionY + ")"); @@ -134,7 +133,8 @@ public class FlightCheck { && !player.hasPotionEffect(PotionEffectType.JUMP) && !(Math.round(movementManager.motionY * 1000) == 425 && movementManager.airTicks == 11) && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig - .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) + .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")) + && movementManager.slimeInfluenceTicks == 0) return new CheckResult(CheckResult.Result.FAILED, "tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")"); // End AirClimb @@ -143,6 +143,7 @@ public class FlightCheck { if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround && Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN)) && Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)) + && Utilities.cantStandAt(distance.getTo().getBlock()) && movementManager.groundTicks > 2) { return new CheckResult(CheckResult.Result.FAILED, "faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")"); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java index c1e8edc..cd2da4c 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java @@ -57,7 +57,7 @@ public class SpeedCheck { boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid; // AirSpeed - if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1 && movementManager.elytraEffectTicks <= 0) { + if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1 && movementManager.elytraEffectTicks <= 0 && !Utilities.isNearClimbable(player)) { double multiplier = 0.985D; double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1); double limit = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "baseLimit"); // Default 0.03125 diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/StrafeCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/StrafeCheck.java new file mode 100644 index 0000000..8e6e96d --- /dev/null +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/StrafeCheck.java @@ -0,0 +1,58 @@ +/* + * AntiCheatReloaded for Bukkit and Spigot. + * Copyright (c) 2012-2015 AntiCheat Team + * Copyright (c) 2016-2020 Rammelkast + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.rammelkast.anticheatreloaded.check.movement; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import com.rammelkast.anticheatreloaded.AntiCheatReloaded; +import com.rammelkast.anticheatreloaded.check.CheckResult; +import com.rammelkast.anticheatreloaded.check.CheckResult.Result; +import com.rammelkast.anticheatreloaded.util.MovementManager; +import com.rammelkast.anticheatreloaded.util.Utilities; + +/** + * + * @author Rammelkast + * + */ +public class StrafeCheck { + + private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); + + public static CheckResult runCheck(Player player, double x, double z, Location from, Location to) { + if (!Utilities.cantStandAtExp(from) || !Utilities.cantStandAtExp(to)) + return PASS; + + MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()) + .getMovementManager(); + + Vector oldAcceleration = new Vector(movementManager.lastDistanceX, 0, movementManager.lastDistanceZ); + Vector newAcceleration = new Vector(x, 0, z); + + // TODO fix false with bouncing off walls + float angle = newAcceleration.angle(oldAcceleration); + double distance = newAcceleration.lengthSquared(); + if (angle > 0.25 && distance > 0.025) + return new CheckResult(Result.FAILED, "switched angle in air (angle=" + angle + ", dist=" + distance + ")"); + return PASS; + } + +} diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java index 888c2b0..a240833 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java @@ -52,7 +52,6 @@ import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; -import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -66,6 +65,7 @@ import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck; import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck; import com.rammelkast.anticheatreloaded.check.movement.FlightCheck; import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck; +import com.rammelkast.anticheatreloaded.check.movement.StrafeCheck; import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck; import com.rammelkast.anticheatreloaded.check.player.IllegalInteract; import com.rammelkast.anticheatreloaded.util.Distance; @@ -486,6 +486,15 @@ public class PlayerListener extends EventListener { log(result.getMessage(), player, CheckType.FASTLADDER); } } + if (getCheckManager().willCheckQuick(player, CheckType.STRAFE)) { + CheckResult result = StrafeCheck.runCheck(player, x, z, event.getFrom(), event.getTo()); + if (result.failed()) { + if (!silentMode()) { + event.setTo(user.getGoodLocation(from.clone())); + } + log(result.getMessage(), player, CheckType.STRAFE); + } + } } if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) { CheckResult result = AimbotCheck.runCheck(player, event); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java index 2e6b8eb..62b5201 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java @@ -45,8 +45,16 @@ public class MovementManager { public double lastMotionY; // Horizontal distance of movement public double distanceXZ; + // Horizontal distance on x-axis of movement + public double distanceX; + // Horizontal distance on z-axis of movement + public double distanceZ; // Previous horizontal distance of movement public double lastDistanceXZ; + // Previous horizontal distance on x-axis of movement + public double lastDistanceX; + // Previous horizontal distance on z-axis of movement + public double lastDistanceZ; // If the player touched the ground again this tick public boolean touchedGroundThisTick = false; // Last recorded distance @@ -84,7 +92,11 @@ public class MovementManager { double x = distance.getXDifference(); double z = distance.getZDifference(); this.lastDistanceXZ = this.distanceXZ; + this.lastDistanceX = this.distanceX; + this.lastDistanceZ = this.distanceZ; this.distanceXZ = Math.sqrt(x * x + z * z); + this.distanceX = x; + this.distanceZ = z; // Account for standing on boat if (Utilities.couldBeOnBoat(player, 0.25, true) && !Utilities.isSubmersed(player)) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java index 092e9a0..20e0bf3 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java @@ -27,7 +27,7 @@ public enum Permission { CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_KILLAURA, CHECK_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER, - CHECK_AIMBOT, + CHECK_AIMBOT, CHECK_STRAFE, /* System Nodes */ SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD, diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java index 5b3dd01..8b3a1db 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java @@ -37,6 +37,7 @@ import org.bukkit.entity.Boat; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.util.BoundingBox; import org.bukkit.util.NumberConversions; public final class Utilities { @@ -226,6 +227,10 @@ public final class Utilities { } public static boolean isHalfblock(Block block) { + BoundingBox box = block.getBoundingBox(); + double height = box.getMaxY() - box.getMinY(); + if (height > 0.42 && height <= 0.6 && block.getType().isSolid()) + return true; return isSlab(block) || isStair(block) || isWall(block) || block.getType() == Material.SNOW; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 248ae70..b196c9a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -127,6 +127,9 @@ permissions: anticheat.check.aimbot: description: Allow players to use aimbot default: false + anticheat.check.aimbot: + description: Allow players to use strafe hacks + default: false anticheat.check.exempt: description: Total exemption from checks default: false @@ -157,4 +160,5 @@ permissions: anticheat.check.unicode: true anticheat.check.illegalinteract: true anticheat.check.fastladder: true - anticheat.check.aimbot: true \ No newline at end of file + anticheat.check.aimbot: true + anticheat.check.strafe: true \ No newline at end of file