diff --git a/pom.xml b/pom.xml index 2e0bb4e..f32b71f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.rammelkast.anticheatreloaded AntiCheatReloaded - 1.9.5 + 1.9.6-PRE AntiCheatReloaded https://www.spigotmc.org/resources/anticheatreloaded.23799/ diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java index 7ac195c..0dcfbc1 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java @@ -231,8 +231,11 @@ public class Backend { if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player) && !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR") - && !VersionUtil.isSlowFalling(player) && !Utilities - .isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation()) && !Utilities.isNearClimbable(player)) { + && !VersionUtil.isSlowFalling(player) + && !Utilities + .isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation()) + && !Utilities.isNearClimbable(player) + && !Utilities.isNearWater(player.getLocation().clone().subtract(0, 1.5, 0))) { if (player.getFallDistance() == 0) { if (nofallViolation.get(uuid) == null) { nofallViolation.put(uuid, 1); @@ -244,8 +247,8 @@ public class Backend { int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag"); if (i >= vlBeforeFlag) { nofallViolation.put(player.getUniqueId(), 1); - return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 " - + i + " times in a row, max=" + vlBeforeFlag + ")"); + return new CheckResult(CheckResult.Result.FAILED, + "tried to avoid fall damage (" + i + " times in a row, max=" + vlBeforeFlag + ")"); } else { return PASS; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java index f88cddc..416d81c 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java @@ -16,7 +16,6 @@ * 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 java.util.HashMap; @@ -31,6 +30,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult.Result; import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.util.Utilities; +import com.rammelkast.anticheatreloaded.util.VersionUtil; public class FastLadderCheck { @@ -38,11 +38,11 @@ public class FastLadderCheck { private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); public static CheckResult runCheck(Player player, double y) { - // Only check if fully on ladder + // Only check if fully on ladder and not flying // Liquids are climbable blocks, so we have to add a seperate check if (!Utilities.isClimbableBlock(player.getLocation().getBlock()) || !Utilities.isClimbableBlock(player.getEyeLocation().getBlock()) - || player.getLocation().getBlock().isLiquid()) { + || player.getLocation().getBlock().isLiquid() || VersionUtil.isFlying(player)) { return PASS; } 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 5d84db4..0e55646 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; +import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffectType; @@ -50,7 +51,8 @@ public class FlightCheck { public static CheckResult runCheck(Player player, Distance distance) { if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN() || VersionUtil.isFlying(player) || player.getVehicle() != null - || AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) { + || AntiCheatReloaded.getManager().getBackend().isMovingExempt(player) + || VersionUtil.isRiptiding(player)) { // This was a teleport or user is flying/using elytra/in a vehicle, so we don't // care // about it. @@ -91,18 +93,26 @@ public class FlightCheck { // Fixes snow false positive if (movementManager.motionY < 0.004 && Utilities .isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation())) - maxMotionY = 0.004D; + maxMotionY += 0.004D; + if (Utilities.isNearWater(player) || Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0))) + maxMotionY += 0.05; if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0 - && !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.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0)) + && 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 + ")"); - if (Math.abs(movementManager.motionY - movementManager.lastMotionY) < 0.01 + if (Math.abs(movementManager.motionY - movementManager.lastMotionY) < 5E-3 && !Utilities.couldBeOnBoat(player) && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig .getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports")) && !VersionUtil.isSlowFalling(player) && !Utilities.isNearWeb(player) - && movementManager.elytraEffectTicks <= 25) + && 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))) return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff=" + Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")"); } @@ -121,8 +131,9 @@ public class FlightCheck { && !player.hasPotionEffect(PotionEffectType.JUMP) && (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()) || ((Utilities.isNearBed(distance.getTo()) + || Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0))) + && movementManager.motionY > 0.15)) && movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) return new CheckResult(CheckResult.Result.FAILED, "AirClimb", "tried to climb air (mY=" + movementManager.motionY + ")"); @@ -160,13 +171,20 @@ public class FlightCheck { double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION; double offset = Math.abs(gravitatedY - movementManager.motionY); double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset"); + if (Utilities.isNearClimbable(distance.getFrom().clone().subtract(0, 0.51D, 0)) + || Utilities.isNearClimbable(distance.getFrom()) || Utilities.isNearWater(player) + || (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0)) + && distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR)) + maxOffset += 0.15D; if (offset > maxOffset && movementManager.airTicks > 2) { int vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1; GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl); int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag"); - if (vl >= vlBeforeFlag) + if (vl >= vlBeforeFlag) { + GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 2)); return new CheckResult(CheckResult.Result.FAILED, "Gravity", "ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")"); + } } else { GRAVITY_VIOLATIONS.remove(player.getUniqueId()); } 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 1970c63..9b918cc 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java @@ -34,7 +34,7 @@ import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.VersionUtil; /** - * @author Rammelkast TODO soulsand speed + * @author Rammelkast TODO soulsand speed TODO buffer system */ public class SpeedCheck { @@ -46,7 +46,8 @@ public class SpeedCheck { public static CheckResult checkXZSpeed(Player player, double x, double z, Location movingTowards) { Backend backend = AntiCheatReloaded.getManager().getBackend(); - if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player)) + if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player) + || VersionUtil.isRiptiding(player)) return PASS; MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()) @@ -201,6 +202,10 @@ public class SpeedCheck { limit *= 1.4D; if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect) limit *= 1.2D; + // Adjust for other effects + if ((movementManager.hasFireResistanceEffect || movementManager.hasBadOmenEffect) + && movementManager.groundTicks > 3) + limit *= 1.2D; if (movementManager.iceInfluenceTicks >= 50) { // When moving off ice if (!Utilities.couldBeOnIce(movingTowards)) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java b/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java index 6b709af..71dc794 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java @@ -82,7 +82,7 @@ public class IllegalInteract { } private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) { - if (!isValidTarget(player, event.getBlock())) { + if (event.getBlock().getType().isSolid() && !isValidTarget(player, event.getBlock())) { return new CheckResult(CheckResult.Result.FAILED, "Place", "tried to place a block out of their view"); } return PASS; diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java index 6a900a6..29321a2 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java @@ -89,6 +89,14 @@ public class MovementManager { public boolean hasSpeedEffect = false; // If the player had speed effect previous tick public boolean hadSpeedEffect = false; + // If the player has a fire resistance effect + public boolean hasFireResistanceEffect = false; + // If the player had fire resistance effect previous tick + public boolean hadFireResistanceEffect = false; + // If the player has a bad omen effect + public boolean hasBadOmenEffect = false; + // If the player had bad omen effect previous tick + public boolean hadBadOmenEffect = false; // Time of last update public long lastUpdate; @@ -180,6 +188,12 @@ public class MovementManager { this.hadSpeedEffect = this.hasSpeedEffect; this.hasSpeedEffect = player.hasPotionEffect(PotionEffectType.SPEED); + + this.hadFireResistanceEffect = this.hasFireResistanceEffect; + this.hasFireResistanceEffect = player.hasPotionEffect(PotionEffectType.FIRE_RESISTANCE); + + this.hadBadOmenEffect = this.hasBadOmenEffect; + this.hasBadOmenEffect = player.hasPotionEffect(PotionEffectType.BAD_OMEN); 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/Utilities.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java index d0090f7..572911d 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java @@ -487,6 +487,26 @@ public final class Utilities { || player.getLocation().getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid(); } + + /** + * Determine whether a location is near a liquid block + * + * @param location Location to check + * @return true if near liquid block + */ + public static boolean isNearWater(Location location) { + return location.getBlock().isLiquid() + || location.getBlock().getRelative(BlockFace.UP).isLiquid() + || location.getBlock().getRelative(BlockFace.DOWN).isLiquid() + || location.getBlock().getRelative(BlockFace.NORTH).isLiquid() + || location.getBlock().getRelative(BlockFace.SOUTH).isLiquid() + || location.getBlock().getRelative(BlockFace.EAST).isLiquid() + || location.getBlock().getRelative(BlockFace.WEST).isLiquid() + || location.getBlock().getRelative(BlockFace.NORTH_EAST).isLiquid() + || location.getBlock().getRelative(BlockFace.NORTH_WEST).isLiquid() + || location.getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid() + || location.getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid(); + } /** * Determine whether a player is surrounded by liquid blocks diff --git a/src/main/resources/checks.yml b/src/main/resources/checks.yml index fb66460..c05c8bc 100644 --- a/src/main/resources/checks.yml +++ b/src/main/resources/checks.yml @@ -18,7 +18,7 @@ flight: accountForTpsDrops: 250 # How many milliseconds to account for teleports # Increase this is you debug 'had too little Y dropoff' after teleports - accountForTeleports: 150 + accountForTeleports: 400 # Checks for climbing behaviour in air # Debugs as 'tried to climb air' airClimb: @@ -26,7 +26,7 @@ flight: enabled: true # How many milliseconds to account for teleports # Increase this is you debug 'tried to climb air' after teleports - accountForTeleports: 50 + accountForTeleports: 150 # Checks if a player is faking it's ground status to fly # Debugs as 'faked ground to fly' groundFlight: @@ -41,7 +41,7 @@ flight: maxOffset: 0.005 # How many milliseconds to account for teleports # Increase this is you debug 'ignored gravity' after teleports - accountForTeleports: 100 + accountForTeleports: 150 # Amount of illegal moves before flagging vlBeforeFlag: 5 @@ -108,7 +108,7 @@ strafe: # Maximum angle change when moving in air maxAngleChange: 0.50 # Minimum movement distance for the strafe check to be active - minActivationDistance: 0.025 + minActivationDistance: 0.04 # WaterWalk check settings # Checks if a player is walking on water