From 6966582e4cc6c2eeb7148ec46833043e7d476693 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Tue, 21 Jul 2020 13:19:35 +0200 Subject: [PATCH] Fixed 3 false positives in water, one with beds and returned to old "getGoodLocation" --- .../check/movement/FlightCheck.java | 6 ++++-- .../check/movement/SpeedCheck.java | 8 ++++++-- .../check/movement/WaterWalkCheck.java | 2 +- .../util/MovementManager.java | 18 ++++++++++++++++++ .../anticheatreloaded/util/User.java | 5 +---- .../anticheatreloaded/util/Utilities.java | 11 +++++++++-- src/main/resources/checks.yml | 2 +- src/main/resources/config.yml | 4 ++-- 8 files changed, 42 insertions(+), 14 deletions(-) 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 4b5b78a..d404841 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java @@ -60,7 +60,7 @@ public class FlightCheck { Backend backend = AntiCheatReloaded.getManager().getBackend(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); - if (Utilities.isNearWater(player) || movementManager.halfMovement + 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))) @@ -115,7 +115,9 @@ public class FlightCheck { && !AntiCheatReloaded.getManager().getBackend().justVelocity(player) && !player.hasPotionEffect(PotionEffectType.JUMP) && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig - .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) + .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")) + && (!Utilities.isNearBed(distance.getTo()) + || (Utilities.isNearBed(distance.getTo()) && movementManager.motionY > 0.12675))) return new CheckResult(CheckResult.Result.FAILED, "tried to climb air (mY=" + movementManager.motionY + ")"); 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 57f2ba2..4fedf42 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java @@ -36,6 +36,7 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil; /** * @author Rammelkast * TODO soulsand speed + * TODO fix false positive with water weeds */ public class SpeedCheck { @@ -207,7 +208,7 @@ public class SpeedCheck { limit *= 0.65D; // Sneak speed check // TODO config - if (player.isSneaking()) + if (movementManager.sneakingTicks > 1) limit *= 0.68D; if (distanceXZ - limit > 0) { @@ -229,13 +230,16 @@ public class SpeedCheck { if (player.isInsideVehicle() || player.isSleeping() || backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_EXTENSION()) || VersionUtil.isFlying(player) - || VersionUtil.isRiptiding(player)) { + || VersionUtil.isRiptiding(player) || Utilities.isNearWater(player)) { return PASS; } double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()), Utilities.couldBeOnBoat(player), Utilities.isClimbableBlock(distance.getFrom().getBlock()) || Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)), movementManager.halfMovement, checksConfig); + // Fix false positive with soulsand boost + if (movementManager.nearLiquidTicks > 6) + maxMotionY *= 1.0525D; if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) { return new CheckResult(CheckResult.Result.FAILED, "exceeded vertical speed limit (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")"); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java index de41949..b98ec78 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java @@ -61,7 +61,7 @@ public class WaterWalkCheck { return new CheckResult(Result.FAILED, "tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")"); - double minAbsMotionY = 0.08D; + double minAbsMotionY = 0.12D; if (player.hasPotionEffect(PotionEffectType.SPEED)) minAbsMotionY += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.05D; if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid() diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java index 620f013..5898a65 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java @@ -67,6 +67,10 @@ public class MovementManager { public int elytraEffectTicks; // Used by Velocity check, represents the currently expected Y motion public double velocityExpectedMotionY; + // Amount of ticks a player is sneaking + public int sneakingTicks; + // Ticks counter after being near a liquid + public int nearLiquidTicks; @SuppressWarnings("deprecation") public void handle(Player player, Location from, Location to, Distance distance) { @@ -121,6 +125,20 @@ public class MovementManager { if (this.elytraEffectTicks > 0) this.elytraEffectTicks--; } + + if (player.isSneaking()) + this.sneakingTicks++; + else + this.sneakingTicks = 0; + + if (Utilities.isNearWater(player)) + this.nearLiquidTicks = 8; + else { + if (this.nearLiquidTicks > 0) + this.nearLiquidTicks--; + else + this.nearLiquidTicks = 0; + } double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference() + this.lastDistance.getZDifference() * this.lastDistance.getZDifference()); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/User.java b/src/main/java/com/rammelkast/anticheatreloaded/util/User.java index 79b4135..1cd025c 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/User.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/User.java @@ -26,7 +26,6 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -237,9 +236,7 @@ public class User { * @return true if the location was valid and set properly */ public boolean setGoodLocation(Location location) { - if (Utilities.cantStandAtExp(location) - || (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location)) - || (!location.getBlock().getType().isSolid() && location.getBlock().getType() != Material.AIR)) { + if (Utilities.cantStandAtExp(location)) { return false; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java index 353636b..692ee16 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java @@ -424,9 +424,16 @@ public final class Utilities { public static boolean isInWater(Player player) { return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() - || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid(); + || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid() + || (!VersionUtil.isBountifulUpdate() + && (player.getLocation().getBlock().getType() == XMaterial.KELP_PLANT.parseMaterial() + || player.getLocation().getBlock().getRelative(BlockFace.UP) + .getType() == XMaterial.KELP_PLANT.parseMaterial() + || player.getLocation().getBlock().getRelative(BlockFace.DOWN) + .getType() == XMaterial.KELP_PLANT.parseMaterial()) + && isNearWater(player)); } - + /** * Determine whether a player is near a liquid block * diff --git a/src/main/resources/checks.yml b/src/main/resources/checks.yml index 5f7cf36..7086a6e 100644 --- a/src/main/resources/checks.yml +++ b/src/main/resources/checks.yml @@ -122,7 +122,7 @@ waterwalk: enabled: true # Minimum xz distance before flagging # This combats false positives, while giving hackers not much leniency - minimumDistXZ: 0.0642 + minimumDistXZ: 0.098 # FastLadder check settings # Checks if a player moves too fast on a ladder diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9c1325b..9c47582 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -35,9 +35,9 @@ system: # Do NOT enable this in a production environment! debug-mode: false # To prevent spamming, staff and the console will only be notified every x violations - # Minimum value is 1, default is 10 + # Minimum value is 1, default is 8 # Example with 5: notifications after 5 vl, 10vl, 15vl, etc. - notify-every-vl: 10 + notify-every-vl: 8 # Use /AntiCheatReloaded checks for a list of valid checks disable-in: - example-world