Compare commits

..
13 Commits
25 changed files with 351 additions and 89 deletions

No files matched your search

+2 -1
View File
@@ -38,7 +38,8 @@ Hacks blocked
* FastBow * FastBow
* FastEat * FastEat
* FastHeal * FastHeal
* KillAura (Aimbot) * KillAura
* Aimbot
* Reach * Reach
* Unicode chat * Unicode chat
* FastProjectile * FastProjectile
+1 -1
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.rammelkast.anticheatreloaded</groupId> <groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheatReloaded</artifactId> <artifactId>AntiCheatReloaded</artifactId>
<version>1.9.0</version> <version>1.9.3</version>
<name>AntiCheatReloaded</name> <name>AntiCheatReloaded</name>
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url> <url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
<properties> <properties>
@@ -29,6 +29,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@@ -153,6 +154,7 @@ public class Backend {
MorePacketsCheck.EXEMPT_TIMINGS.remove(uuid); MorePacketsCheck.EXEMPT_TIMINGS.remove(uuid);
ElytraCheck.JUMP_Y_VALUE.remove(uuid); ElytraCheck.JUMP_Y_VALUE.remove(uuid);
KillAuraCheck.ANGLE_FLAGS.remove(uuid); KillAuraCheck.ANGLE_FLAGS.remove(uuid);
KillAuraCheck.PACKETORDER_FLAGS.remove(uuid);
FlightCheck.MOVING_EXEMPT.remove(uuid); FlightCheck.MOVING_EXEMPT.remove(uuid);
} }
@@ -229,7 +231,8 @@ public class Backend {
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
&& !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player) && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player)
&& !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR") && !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")
&& !VersionUtil.isSlowFalling(player)) { && !VersionUtil.isSlowFalling(player) && !Utilities
.isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation())) {
if (player.getFallDistance() == 0) { if (player.getFallDistance() == 0) {
if (nofallViolation.get(uuid) == null) { if (nofallViolation.get(uuid) == null) {
nofallViolation.put(uuid, 1); nofallViolation.put(uuid, 1);
@@ -62,7 +62,8 @@ public enum CheckType {
CHAT_UNICODE(Permission.CHECK_UNICODE, "ChatUnicode"), CHAT_UNICODE(Permission.CHECK_UNICODE, "ChatUnicode"),
ILLEGAL_INTERACT(Permission.CHECK_ILLEGALINTERACT, "IllegalInteract"), ILLEGAL_INTERACT(Permission.CHECK_ILLEGALINTERACT, "IllegalInteract"),
FASTLADDER(Permission.CHECK_FASTLADDER, "FastLadder"), 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 Permission permission;
private final String displayName; private final String displayName;
@@ -32,7 +32,9 @@ import org.bukkit.util.Vector;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.util.MovementManager;
import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
@@ -40,6 +42,8 @@ public class KillAuraCheck {
// Angle check // Angle check
public static final Map<UUID, Integer> ANGLE_FLAGS = new HashMap<UUID, Integer>(); public static final Map<UUID, Integer> ANGLE_FLAGS = new HashMap<UUID, Integer>();
// PacketOrder check
public static final Map<UUID, Integer> PACKETORDER_FLAGS = new HashMap<UUID, Integer>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult checkReach(Player player, Entity target) { public static CheckResult checkReach(Player player, Entity target) {
@@ -118,6 +122,39 @@ public class KillAuraCheck {
return PASS; return PASS;
} }
public static CheckResult checkPacketOrder(Player player, Entity entity) {
UUID uuid = player.getUniqueId();
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
MovementManager movementManager = user.getMovementManager();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
// Check if enabled
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "packetOrder"))
return PASS;
if (user.isLagging() || (System.currentTimeMillis() - movementManager.lastTeleport) <= 100
|| AntiCheatReloaded.getPlugin().getTPS() < checksConfig.getDouble(CheckType.KILLAURA, "packetOrder", "minimumTps"))
return PASS;
long elapsed = System.currentTimeMillis() - movementManager.lastUpdate;
if (elapsed < checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "minElapsedTime")) {
if (!PACKETORDER_FLAGS.containsKey(uuid)) {
PACKETORDER_FLAGS.put(uuid, 1);
return PASS;
}
int flags = PACKETORDER_FLAGS.get(uuid);
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "vlBeforeFlag");
if (flags >= vlBeforeFlag) {
PACKETORDER_FLAGS.remove(uuid);
return new CheckResult(Result.FAILED, "suspicious packet order (elapsed=" + elapsed + ")");
}
PACKETORDER_FLAGS.put(uuid, flags + 1);
}
return PASS;
}
public static double calculateYawDifference(Location from, Location to) { public static double calculateYawDifference(Location from, Location to) {
Location clonedFrom = from.clone(); Location clonedFrom = from.clone();
Vector startVector = clonedFrom.toVector(); Vector startVector = clonedFrom.toVector();
@@ -30,6 +30,7 @@ import org.bukkit.potion.PotionEffectType;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class ElytraCheck { public class ElytraCheck {
@@ -38,10 +39,9 @@ public class ElytraCheck {
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(Player player, Distance distance) {
// No elytra in server version // No elytra in server version or not relevant
if (VersionUtil.isBountifulUpdate()) { if (VersionUtil.isBountifulUpdate() || Utilities.isNearWater(player))
return PASS; return PASS;
}
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) { if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
@@ -49,8 +49,10 @@ public class FlightCheck {
public static CheckResult runCheck(Player player, Distance distance) { public static CheckResult runCheck(Player player, Distance distance) {
if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN() if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|| VersionUtil.isFlying(player)) { || VersionUtil.isFlying(player) || player.getVehicle() != null
// This was a teleport or user is flying/using elytra, so we don't care || AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) {
// This was a teleport or user is flying/using elytra/in a vehicle, so we don't
// care
// about it. // about it.
return PASS; return PASS;
} }
@@ -60,23 +62,19 @@ public class FlightCheck {
Backend backend = AntiCheatReloaded.getManager().getBackend(); Backend backend = AntiCheatReloaded.getManager().getBackend();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement || Utilities.isNearClimbable(player))
|| Utilities.isClimbableBlock(distance.getFrom().getBlock())
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.UP)))
return PASS; return PASS;
int minAirTicks = 13; int minAirTicks = 13;
if (player.hasPotionEffect(PotionEffectType.JUMP)) { if (player.hasPotionEffect(PotionEffectType.JUMP))
minAirTicks += player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() * 3; minAirTicks += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 3;
}
if (movementManager.halfMovementHistoryCounter > 25) if (movementManager.halfMovementHistoryCounter > 25)
minAirTicks += 5; minAirTicks += 5;
// Start AirFlight // Start AirFlight
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks
&& !backend.justVelocity(player)) { && !backend.justVelocity(player) && movementManager.elytraEffectTicks <= 25) {
// Config default base is 1200ms // Config default base is 1200ms
// Ping clamped to max. 1000 to prevent spoofing for an advantage // Ping clamped to max. 1000 to prevent spoofing for an advantage
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight", int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
@@ -90,7 +88,12 @@ public class FlightCheck {
? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId()) ? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId())
: (blockPlaceAccountingTime + 1); : (blockPlaceAccountingTime + 1);
double maxMotionY = System.currentTimeMillis() - lastPlacedBlock > blockPlaceAccountingTime ? 0 : 0.42; double maxMotionY = System.currentTimeMillis() - lastPlacedBlock > blockPlaceAccountingTime ? 0 : 0.42;
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) // Fixes snow false positive
if (movementManager.motionY < 0.004 && Utilities
.isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation()))
maxMotionY = 0.004D;
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 1.25, 0)))
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
"tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")"); "tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
@@ -98,18 +101,20 @@ public class FlightCheck {
&& !Utilities.couldBeOnBoat(player) && !Utilities.couldBeOnBoat(player)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports")) .getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
&& !VersionUtil.isSlowFalling(player) && !Utilities.isInWeb(player)) && !VersionUtil.isSlowFalling(player) && !Utilities.isInWeb(player)
&& movementManager.elytraEffectTicks <= 25)
return new CheckResult(CheckResult.Result.FAILED, "had too little Y dropoff (diff=" return new CheckResult(CheckResult.Result.FAILED, "had too little Y dropoff (diff="
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")"); + Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
} }
// End AirFlight // End AirFlight
// Start AirClimb // Start AirClimb
// TODO two hardcoded values here shouldn't be there, temp against false // TODO three hardcoded values here shouldn't be there, temp against false
// positive // positive
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0 if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0
&& movementManager.motionY > 0 && movementManager.airTicks == 2 && movementManager.motionY > 0 && movementManager.airTicks == 2
&& Math.round(movementManager.lastMotionY * 1000) != 420 && Math.round(movementManager.lastMotionY * 1000) != 420
&& Math.round(movementManager.motionY * 1000) != 248
&& !(Math.round(movementManager.motionY * 1000) == 333 && !(Math.round(movementManager.motionY * 1000) == 333
&& Math.round(movementManager.lastMotionY * 1000) != 333) && Math.round(movementManager.lastMotionY * 1000) != 333)
&& !AntiCheatReloaded.getManager().getBackend().justVelocity(player) && !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
@@ -117,24 +122,29 @@ public class FlightCheck {
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")) .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
&& (!Utilities.isNearBed(distance.getTo()) && (!Utilities.isNearBed(distance.getTo())
|| (Utilities.isNearBed(distance.getTo()) && movementManager.motionY > 0.12675))) || (Utilities.isNearBed(distance.getTo()) && movementManager.motionY > 0.12675))
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25)
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
"tried to climb air (mY=" + movementManager.motionY + ")"); "tried to climb air (mY=" + movementManager.motionY + ")");
// TODO hardcoded value against false again..
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42 if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42
&& movementManager.airTicks > 2 && !AntiCheatReloaded.getManager().getBackend().justVelocity(player) && movementManager.airTicks > 2 && !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !player.hasPotionEffect(PotionEffectType.JUMP)
&& !(Math.round(movementManager.motionY * 1000) == 425 && movementManager.airTicks == 11)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")"); "tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
}
// End AirClimb // End AirClimb
// Start GroundFlight // Start GroundFlight
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround
&& Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN)) && Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN))
&& Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)) && Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
&& movementManager.groundTicks > 2) { && Utilities.cantStandAt(distance.getTo().getBlock()) && movementManager.groundTicks > 2) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
"faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")"); "faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")");
} }
@@ -145,7 +155,7 @@ public class FlightCheck {
&& movementManager.motionY < 0 && !backend.justVelocity(player) && movementManager.motionY < 0 && !backend.justVelocity(player)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports")) .getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
&& !Utilities.isInWeb(player)) { && !Utilities.isInWeb(player) && movementManager.elytraEffectTicks <= 25) {
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION; double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
double offset = Math.abs(gravitatedY - movementManager.motionY); double offset = Math.abs(gravitatedY - movementManager.motionY);
double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset"); double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
@@ -36,7 +36,6 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
/** /**
* @author Rammelkast * @author Rammelkast
* TODO soulsand speed * TODO soulsand speed
* TODO fix false positive with water weeds
*/ */
public class SpeedCheck { public class SpeedCheck {
@@ -58,7 +57,7 @@ public class SpeedCheck {
boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid; boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
// AirSpeed // 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 multiplier = 0.985D;
double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1); double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1);
double limit = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "baseLimit"); // Default 0.03125 double limit = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "baseLimit"); // Default 0.03125
@@ -87,10 +86,10 @@ public class SpeedCheck {
} }
// Adjust for speed effects // Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED)) if (player.hasPotionEffect(PotionEffectType.SPEED))
predict += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.05D; predict += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
// Adjust for jump boost effects // Adjust for jump boost effects
if (player.hasPotionEffect(PotionEffectType.JUMP)) if (player.hasPotionEffect(PotionEffectType.JUMP))
predict += (player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() + 1) * 0.05D; predict += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.05D;
// Adjust for custom walking speed // Adjust for custom walking speed
double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "walkSpeedMultiplier"); // Default 1.4 double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "walkSpeedMultiplier"); // Default 1.4
predict += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1); predict += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
@@ -100,7 +99,7 @@ public class SpeedCheck {
if (Utilities.couldBeOnHalfblock(movingTowards) && movementManager.halfMovementHistoryCounter == 0) if (Utilities.couldBeOnHalfblock(movingTowards) && movementManager.halfMovementHistoryCounter == 0)
predict *= 1.25D; predict *= 1.25D;
// Boats sometimes give a false positive // Boats sometimes give a false positive
if (Utilities.couldBeOnBoat(player, 0.5)) if (Utilities.couldBeOnBoat(player, 0.5, true))
predict *= 1.25D; predict *= 1.25D;
// Strafing in air when nearing terminal velocity gives false positives // Strafing in air when nearing terminal velocity gives false positives
// This fixes the issue but gives hackers some leniency which means we need another check for this // This fixes the issue but gives hackers some leniency which means we need another check for this
@@ -137,7 +136,7 @@ public class SpeedCheck {
limit *= 1.05D; limit *= 1.05D;
// Adjust for speed effects // Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED)) if (player.hasPotionEffect(PotionEffectType.SPEED))
limit += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.0225D; limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
// Adjust for slabs // Adjust for slabs
if (movementManager.halfMovementHistoryCounter > 15) if (movementManager.halfMovementHistoryCounter > 15)
limit *= 2.0D; limit *= 2.0D;
@@ -184,7 +183,7 @@ public class SpeedCheck {
limit *= 1.1D; limit *= 1.1D;
// Adjust for speed effects // Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED)) if (player.hasPotionEffect(PotionEffectType.SPEED))
limit += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.06D; limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.06D;
if (movementManager.iceInfluenceTicks >= 50) { if (movementManager.iceInfluenceTicks >= 50) {
// When moving off ice // When moving off ice
if (!Utilities.couldBeOnIce(movingTowards)) if (!Utilities.couldBeOnIce(movingTowards))
@@ -229,18 +228,15 @@ public class SpeedCheck {
public static CheckResult checkVerticalSpeed(Player player, Distance distance) { public static CheckResult checkVerticalSpeed(Player player, Distance distance) {
Backend backend = AntiCheatReloaded.getManager().getBackend(); Backend backend = AntiCheatReloaded.getManager().getBackend();
if (isSpeedExempt(player, backend) || player.getVehicle() != null || player.isSleeping()
|| VersionUtil.isRiptiding(player) || Utilities.isNearWater(player))
return PASS;
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()) MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
.getMovementManager(); .getMovementManager();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed")) if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed"))
return PASS; return PASS;
if (player.isInsideVehicle() || player.isSleeping()
|| backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_EXTENSION()) || VersionUtil.isFlying(player)
|| VersionUtil.isRiptiding(player) || Utilities.isNearWater(player)) {
return PASS;
}
double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()), double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()),
Utilities.couldBeOnBoat(player), Utilities.isClimbableBlock(distance.getFrom().getBlock()) Utilities.couldBeOnBoat(player), Utilities.isClimbableBlock(distance.getFrom().getBlock())
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)), movementManager.halfMovement, checksConfig); || Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)), movementManager.halfMovement, checksConfig);
@@ -257,12 +253,12 @@ public class SpeedCheck {
private static double getMaxAcceptableMotionY(Player player, boolean nearBed, boolean couldBeOnBoat, boolean fromClimbable, boolean halfMovement, Checks checksConfig) { private static double getMaxAcceptableMotionY(Player player, boolean nearBed, boolean couldBeOnBoat, boolean fromClimbable, boolean halfMovement, Checks checksConfig) {
// TODO config for these values // TODO config for these values
// TODO something funky vanilla stuff going on with 0.42, like 0.445.., check this.. // TODO something funky vanilla stuff going on with 0.42, like 0.445.., check this..
double base = couldBeOnBoat ? 0.600000025 : (nearBed ? 0.5625 : (halfMovement ? 0.6 : 0.42)); double base = couldBeOnBoat ? 0.600000025 : (nearBed ? 0.5625 : ((halfMovement || VersionUtil.isBountifulUpdate()) ? 0.6 : 0.42));
if (fromClimbable) if (fromClimbable)
base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04 base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
base += player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() * 0.2D; if (player.hasPotionEffect(PotionEffectType.JUMP))
} base += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.2D;
return base; return base;
} }
@@ -0,0 +1,67 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
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.CheckType;
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
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) || Utilities.isNearWater(player)
|| Utilities.isNearClimbable(player))
return PASS;
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
.getMovementManager();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig.getInteger(CheckType.STRAFE,
"accountForTeleports") || movementManager.elytraEffectTicks >= 20)
return PASS;
Vector oldAcceleration = new Vector(movementManager.lastDistanceX, 0, movementManager.lastDistanceZ);
Vector newAcceleration = new Vector(x, 0, z);
float angle = newAcceleration.angle(oldAcceleration);
double distance = newAcceleration.lengthSquared();
if (angle > checksConfig
.getDouble(CheckType.STRAFE, "maxAngleChange") && distance > checksConfig
.getDouble(CheckType.STRAFE, "minActivationDistance") && Utilities.cantStandFar(to.getBlock()))
return new CheckResult(Result.FAILED, "switched angle in air (angle=" + angle + ", dist=" + distance + ")");
return PASS;
}
}
@@ -32,6 +32,7 @@ import com.rammelkast.anticheatreloaded.config.providers.Checks;
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; import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class WaterWalkCheck { public class WaterWalkCheck {
@@ -42,28 +43,31 @@ public class WaterWalkCheck {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid); User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
MovementManager movementManager = user.getMovementManager(); MovementManager movementManager = user.getMovementManager();
if (movementManager.distanceXZ <= 0) if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player)
|| VersionUtil.isRiptiding(player) || VersionUtil.isSwimming(player))
return PASS; return PASS;
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock(); Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock();
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "walk") && blockBeneath.isLiquid() if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "walk") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player) && Utilities.isSurroundedByWater(player)
&& ((movementManager.motionY == 0 && movementManager.lastMotionY == 0) || movementManager.motionY == Utilities.JUMP_MOTION_Y) && ((movementManager.motionY == 0 && movementManager.lastMotionY == 0)
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")) || movementManager.motionY == Utilities.JUMP_MOTION_Y)
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")
&& !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false))
return new CheckResult(Result.FAILED, return new CheckResult(Result.FAILED,
"tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")"); "tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")");
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid() if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player) && movementManager.onGround && Utilities.isSurroundedByWater(player) && movementManager.onGround
&& Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")) && Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")
&& !Utilities.couldBeOnBoat(player, 0.3, false))
return new CheckResult(Result.FAILED, return new CheckResult(Result.FAILED,
"tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")"); "tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")");
double minAbsMotionY = 0.12D; double minAbsMotionY = 0.12D;
if (player.hasPotionEffect(PotionEffectType.SPEED)) if (player.hasPotionEffect(PotionEffectType.SPEED))
minAbsMotionY += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.05D; minAbsMotionY += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid() if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player) && Utilities.isSurroundedByWater(player)
&& Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY && Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
@@ -32,6 +32,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks; 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.User; import com.rammelkast.anticheatreloaded.util.User;
public class BadPacketsCheck { public class BadPacketsCheck {
@@ -39,9 +40,10 @@ public class BadPacketsCheck {
public static void runCheck(Player player, PacketEvent event) { public static void runCheck(Player player, PacketEvent event) {
Backend backend = AntiCheatReloaded.getManager().getBackend(); Backend backend = AntiCheatReloaded.getManager().getBackend();
// Confirm if we should even check for BadPackets // Confirm if we should even check for BadPackets
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS) || backend.isMovingExempt(player)) { if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS)
|| backend.isMovingExempt(player) || player.isDead())
return; return;
}
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
PacketContainer packet = event.getPacket(); PacketContainer packet = event.getPacket();
float pitch = packet.getFloat().read(1); float pitch = packet.getFloat().read(1);
@@ -53,9 +55,11 @@ public class BadPacketsCheck {
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
double tps = AntiCheatReloaded.getPlugin().getTPS(); double tps = AntiCheatReloaded.getPlugin().getTPS();
if (user.isLagging() || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")) { MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
.getMovementManager();
if (user.isLagging() || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")
|| (System.currentTimeMillis() - movementManager.lastTeleport <= 100))
return; return;
}
double x = packet.getDoubles().read(0); double x = packet.getDoubles().read(0);
double y = packet.getDoubles().read(1); double y = packet.getDoubles().read(1);
@@ -68,7 +72,8 @@ public class BadPacketsCheck {
double maxDistance = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance"); double maxDistance = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance");
boolean hasNewLocation = packet.getBooleans().read(0); boolean hasNewLocation = packet.getBooleans().read(0);
if (distance > maxDistance) { if (distance > maxDistance) {
flag(player, event, "moved too far between packets (distance=" + new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ")"); flag(player, event, "moved too far between packets (distance="
+ new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ")");
return; return;
} else if (distance < 1E-10 && !hasNewLocation) { } else if (distance < 1E-10 && !hasNewLocation) {
// TODO this gives false positives when teleporting // TODO this gives false positives when teleporting
@@ -66,7 +66,7 @@ public class CommandBase {
execute(cs, args); execute(cs, args);
} else { } else {
if (args == null) { if (args == null) {
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "AntiCheatReloaded " + GRAY + "version " + AntiCheatReloaded.getVersion()); cs.sendMessage(GRAY + "Running " + GOLD + "" + "AntiCheatReloaded " + GRAY + "version " + AntiCheatReloaded.getVersion());
} else { } else {
cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")"); cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")");
} }
@@ -51,6 +51,7 @@ public class Config extends ConfigurationFile {
public ConfigValue<List<String>> disabledWorlds; public ConfigValue<List<String>> disabledWorlds;
public ConfigValue<Integer> notifyEveryVl; public ConfigValue<Integer> notifyEveryVl;
public ConfigValue<Integer> maxSetbackDistance;
public Config(AntiCheatReloaded plugin, Configuration config) { public Config(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME); super(plugin, config, FILENAME);
@@ -85,5 +86,10 @@ public class Config extends ConfigurationFile {
if (notifyEveryVl.getValue() < 1) { if (notifyEveryVl.getValue() < 1) {
notifyEveryVl.setValue(5); notifyEveryVl.setValue(5);
} }
maxSetbackDistance = new ConfigValue<Integer>("system.max-setback-distance");
if (maxSetbackDistance.getValue() < 5) {
maxSetbackDistance.setValue(50);
}
} }
} }
@@ -32,6 +32,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
@@ -134,9 +135,8 @@ public class EntityListener extends EventListener {
} }
} }
} }
if (e.getDamager() instanceof Player) { if (e.getDamager() instanceof Player && event.getCause() == DamageCause.ENTITY_ATTACK) {
Player player = (Player) e.getDamager(); Player player = (Player) e.getDamager();
getBackend().logDamage(player, 1);
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) { if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
CheckResult result = KillAuraCheck.checkAngle(player, event); CheckResult result = KillAuraCheck.checkAngle(player, event);
if (result.failed()) { if (result.failed()) {
@@ -153,6 +153,14 @@ public class EntityListener extends EventListener {
noHack = false; noHack = false;
} }
} }
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
CheckResult result = KillAuraCheck.checkPacketOrder(player, event.getEntity());
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.KILLAURA);
noHack = false;
}
}
if (noHack) { if (noHack) {
decrease(player); decrease(player);
} }
@@ -65,6 +65,7 @@ import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck; import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck; import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck; 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.movement.WaterWalkCheck;
import com.rammelkast.anticheatreloaded.check.player.IllegalInteract; import com.rammelkast.anticheatreloaded.check.player.IllegalInteract;
import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.Distance;
@@ -256,9 +257,6 @@ public class PlayerListener extends EventListener {
@EventHandler @EventHandler
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) { public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!event.isSprinting()) {
getBackend().logEnterExit(player);
}
if (getCheckManager().willCheck(player, CheckType.SPRINT)) { if (getCheckManager().willCheck(player, CheckType.SPRINT)) {
CheckResult result = getBackend().checkSprintHungry(event); CheckResult result = getBackend().checkSprintHungry(event);
if (result.failed()) { if (result.failed()) {
@@ -436,7 +434,6 @@ public class PlayerListener extends EventListener {
} }
} }
boolean changed = false;
if (event.getTo() != event.getFrom()) { if (event.getTo() != event.getFrom()) {
double x = distance.getXDifference(); double x = distance.getXDifference();
double z = distance.getZDifference(); double z = distance.getZDifference();
@@ -449,7 +446,6 @@ public class PlayerListener extends EventListener {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(result.getMessage(), player, CheckType.SPEED); log(result.getMessage(), player, CheckType.SPEED);
changed = true;
} }
} }
CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo()); CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo());
@@ -458,7 +454,6 @@ public class PlayerListener extends EventListener {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(result.getMessage(), player, CheckType.SPEED); log(result.getMessage(), player, CheckType.SPEED);
changed = true;
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) { if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
@@ -469,7 +464,6 @@ public class PlayerListener extends EventListener {
player.teleport(player.getLocation().clone().subtract(0, 0.52, 0)); player.teleport(player.getLocation().clone().subtract(0, 0.52, 0));
} }
log(result.getMessage(), player, CheckType.WATER_WALK); log(result.getMessage(), player, CheckType.WATER_WALK);
changed = true;
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) { if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
@@ -479,7 +473,6 @@ public class PlayerListener extends EventListener {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(result.getMessage(), player, CheckType.SPIDER); log(result.getMessage(), player, CheckType.SPIDER);
changed = true;
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) { if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) {
@@ -491,11 +484,16 @@ public class PlayerListener extends EventListener {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
} }
log(result.getMessage(), player, CheckType.FASTLADDER); log(result.getMessage(), player, CheckType.FASTLADDER);
changed = true;
} }
} }
if (!changed) { if (getCheckManager().willCheckQuick(player, CheckType.STRAFE)) {
user.setGoodLocation(event.getFrom()); 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)) { if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) {
@@ -21,6 +21,8 @@ package com.rammelkast.anticheatreloaded.util;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
public class MovementManager { public class MovementManager {
// Ticks in air // Ticks in air
@@ -43,8 +45,16 @@ public class MovementManager {
public double lastMotionY; public double lastMotionY;
// Horizontal distance of movement // Horizontal distance of movement
public double distanceXZ; 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 // Previous horizontal distance of movement
public double lastDistanceXZ; 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 // If the player touched the ground again this tick
public boolean touchedGroundThisTick = false; public boolean touchedGroundThisTick = false;
// Last recorded distance // Last recorded distance
@@ -71,6 +81,8 @@ public class MovementManager {
public int sneakingTicks; public int sneakingTicks;
// Ticks counter after being near a liquid // Ticks counter after being near a liquid
public int nearLiquidTicks; public int nearLiquidTicks;
// Time of last update
public long lastUpdate;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void handle(Player player, Location from, Location to, Distance distance) { public void handle(Player player, Location from, Location to, Distance distance) {
@@ -82,10 +94,14 @@ public class MovementManager {
double x = distance.getXDifference(); double x = distance.getXDifference();
double z = distance.getZDifference(); double z = distance.getZDifference();
this.lastDistanceXZ = this.distanceXZ; this.lastDistanceXZ = this.distanceXZ;
this.lastDistanceX = this.distanceX;
this.lastDistanceZ = this.distanceZ;
this.distanceXZ = Math.sqrt(x * x + z * z); this.distanceXZ = Math.sqrt(x * x + z * z);
this.distanceX = x;
this.distanceZ = z;
// Account for standing on boat // Account for standing on boat
if (Utilities.couldBeOnBoat(player, 0.25)) if (Utilities.couldBeOnBoat(player, 0.25, true) && !Utilities.isSubmersed(player))
this.onGround = true; this.onGround = true;
this.touchedGroundThisTick = false; this.touchedGroundThisTick = false;
@@ -154,12 +170,17 @@ public class MovementManager {
Location bottom = to.clone().add(0, -1, 0); Location bottom = to.clone().add(0, -1, 0);
this.bottomSolid = bottom.getBlock().getType().isSolid(); this.bottomSolid = bottom.getBlock().getType().isSolid();
if ((this.motionY > 0.464D && this.motionY <= 0.5625D) && (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) { if ((this.motionY > 0.42D && this.motionY <= 0.5625D)
&& (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) {
this.halfMovement = true; this.halfMovement = true;
this.halfMovementHistoryCounter = 30; this.halfMovementHistoryCounter = 30;
} else { } else {
if (this.halfMovementHistoryCounter > 0) if (this.halfMovementHistoryCounter > 0)
this.halfMovementHistoryCounter--; this.halfMovementHistoryCounter--;
} }
this.lastUpdate = System.currentTimeMillis();
// Update "good location"
AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).setGoodLocation(from);
} }
} }
@@ -27,7 +27,7 @@ public enum Permission {
CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, 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_KILLAURA, CHECK_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY,
CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER,
CHECK_AIMBOT, CHECK_AIMBOT, CHECK_STRAFE,
/* System Nodes */ /* System Nodes */
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD, SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD,
@@ -217,7 +217,8 @@ public class User {
* @return last known valid location * @return last known valid location
*/ */
public Location getGoodLocation(Location location) { public Location getGoodLocation(Location location) {
if (goodLocation == null) { if (goodLocation == null || !location.getWorld().equals(goodLocation.getWorld())
|| location.distance(goodLocation) > config.getConfig().maxSetbackDistance.getValue()) {
return location; return location;
} }
@@ -457,7 +458,8 @@ public class User {
} }
public boolean isLagging() { public boolean isLagging() {
return Math.abs(this.ping - this.lastPing) > config.getMagic().LAG_DETERMINATION(); return Math.abs(this.ping - this.lastPing) > config.getMagic().LAG_DETERMINATION()
&& this.ping > config.getMagic().LAG_DETERMINATION();
} }
public MovementManager getMovementManager() { public MovementManager getMovementManager() {
@@ -37,6 +37,7 @@ import org.bukkit.entity.Boat;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
public final class Utilities { public final class Utilities {
@@ -47,7 +48,6 @@ public final class Utilities {
public static final Material LILY_PAD; public static final Material LILY_PAD;
public static final Material COB_WEB; public static final Material COB_WEB;
public static final Material IRON_BARS;
public static final double JUMP_MOTION_Y = 0.41999998688697815; public static final double JUMP_MOTION_Y = 0.41999998688697815;
@@ -124,13 +124,18 @@ public final class Utilities {
} }
public static boolean couldBeOnBoat(Player player) { public static boolean couldBeOnBoat(Player player) {
return couldBeOnBoat(player, 0.35); return couldBeOnBoat(player, 0.35, false);
} }
public static boolean couldBeOnBoat(Player player, double range) { public static boolean couldBeOnBoat(Player player, double range, boolean checkY) {
for (Entity entity : player.getNearbyEntities(range, range, range)) { for (Entity entity : player.getNearbyEntities(range, range, range)) {
if (entity instanceof Boat) if (entity instanceof Boat) {
if (((Boat) entity).getLocation().getY() < player.getLocation().getY() + 0.25) {
return true; return true;
} else if (!checkY) {
return true;
}
}
} }
return false; return false;
} }
@@ -171,6 +176,31 @@ public final class Utilities {
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_WEST)); || isIce(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
} }
/**
* Determine whether a block is a shulker box
*
* @param block block to check
* @return true if block is a shulker box
*/
public static boolean isShulkerBox(Block block) {
Material type = block.getType();
return type.name().endsWith("SHULKER_BOX");
}
public static boolean isNearShulkerBox(Location location) {
if (VersionUtil.isBountifulUpdate())
return false;
return isShulkerBox(location.getBlock())
|| isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.EAST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.WEST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
/** /**
* Determine whether a player could be standing on a halfblock * Determine whether a player could be standing on a halfblock
* *
@@ -196,7 +226,13 @@ public final class Utilities {
} }
public static boolean isHalfblock(Block block) { public static boolean isHalfblock(Block block) {
return isSlab(block) || isStair(block) || isWall(block); if (!VersionUtil.isBountifulUpdate()) {
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;
} }
@@ -377,7 +413,7 @@ public final class Utilities {
*/ */
public static boolean isWall(Block block) { public static boolean isWall(Block block) {
Material type = block.getType(); Material type = block.getType();
return type.name().endsWith("WALL"); return type.name().endsWith("WALL") || type.name().endsWith("FENCE");
} }
/** /**
@@ -501,6 +537,22 @@ public final class Utilities {
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.WEST)); || isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.WEST));
} }
/**
* Determine whether a location is near a climbable block
*
* @param location location to check
* @return true if near climbable block
*/
public static boolean isNearClimbable(Location location) {
return isClimbableBlock(location.getBlock())
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.DOWN))
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.UP))
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.NORTH))
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.SOUTH))
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.EAST))
|| isClimbableBlock(location.getBlock().getRelative(BlockFace.WEST));
}
/** /**
* Determine whether a block is climbable * Determine whether a block is climbable
* *
@@ -713,7 +765,6 @@ public final class Utilities {
if (VersionUtil.isBountifulUpdate()) { if (VersionUtil.isBountifulUpdate()) {
LILY_PAD = XMaterial.LILY_PAD.parseMaterial(); LILY_PAD = XMaterial.LILY_PAD.parseMaterial();
COB_WEB = XMaterial.COBWEB.parseMaterial(); COB_WEB = XMaterial.COBWEB.parseMaterial();
IRON_BARS = XMaterial.IRON_BARS.parseMaterial();
// Start instant break materials // Start instant break materials
INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial()); INSTANT_BREAK.add(XMaterial.COMPARATOR.parseMaterial());
@@ -797,7 +848,6 @@ public final class Utilities {
else { else {
LILY_PAD = Material.LILY_PAD; LILY_PAD = Material.LILY_PAD;
COB_WEB = Material.COBWEB; COB_WEB = Material.COBWEB;
IRON_BARS = Material.IRON_BARS;
// Start instant break materials // Start instant break materials
INSTANT_BREAK.add(Material.COMPARATOR); INSTANT_BREAK.add(Material.COMPARATOR);
@@ -936,7 +986,8 @@ public final class Utilities {
CLIMBABLE.add(Material.LADDER); CLIMBABLE.add(Material.LADDER);
CLIMBABLE.add(Material.WATER); CLIMBABLE.add(Material.WATER);
// Start 1.14 objects // Start 1.14 objects
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) { if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15")
|| VersionUtil.isOfVersion("v1_16")) {
CLIMBABLE.add(Material.SCAFFOLDING); CLIMBABLE.add(Material.SCAFFOLDING);
} }
// End 1.14 objects // End 1.14 objects
@@ -946,7 +997,7 @@ public final class Utilities {
CLIMBABLE.add(XMaterial.TWISTING_VINES.parseMaterial()); CLIMBABLE.add(XMaterial.TWISTING_VINES.parseMaterial());
CLIMBABLE.add(XMaterial.TWISTING_VINES_PLANT.parseMaterial()); CLIMBABLE.add(XMaterial.TWISTING_VINES_PLANT.parseMaterial());
CLIMBABLE.add(XMaterial.WEEPING_VINES.parseMaterial()); CLIMBABLE.add(XMaterial.WEEPING_VINES.parseMaterial());
CLIMBABLE.add(XMaterial.TWISTING_VINES_PLANT.parseMaterial()); CLIMBABLE.add(XMaterial.WEEPING_VINES_PLANT.parseMaterial());
} }
// End 1.16 objects // End 1.16 objects
// End climbable // End climbable
@@ -134,4 +134,24 @@ public class VersionUtil {
return effect.getType().equals(PotionEffectType.LEVITATION); return effect.getType().equals(PotionEffectType.LEVITATION);
} }
public static int getPotionLevel(Player player, PotionEffectType type) {
if (isBountifulUpdate()) {
for (PotionEffect effect : player.getActivePotionEffects()) {
if (effect.getType().equals(type))
return effect.getAmplifier() + 1;
}
return 0;
}
if (player.hasPotionEffect(type))
return player.getPotionEffect(type).getAmplifier() + 1;
return 0;
}
public static boolean isSwimming(Player player) {
if (isBountifulUpdate()) {
return false;
}
return player.isSwimming();
}
} }
+25 -1
View File
@@ -98,6 +98,18 @@ speed:
# Extra compensation when moving off a ladder up a slab # Extra compensation when moving off a ladder up a slab
climbableCompensation: 0.04 climbableCompensation: 0.04
# Strafe check settings
# Checks if a player switches movement angle in air
strafe:
# Should this check be enabled?
enabled: true
# How many milliseconds to account for teleports
accountForTeleports: 100
# Maximum angle change when moving in air
maxAngleChange: 0.25
# Minimum movement distance for the strafe check to be active
minActivationDistance: 0.025
# WaterWalk check settings # WaterWalk check settings
# Checks if a player is walking on water # Checks if a player is walking on water
waterwalk: waterwalk:
@@ -170,6 +182,18 @@ killaura:
# Amount of illegally angled hits before flagging # Amount of illegally angled hits before flagging
vlBeforeFlag: 3 vlBeforeFlag: 3
# Checks if the player has a suspicious packet order
# Debugs as 'suspicious packet order'
packetOrder:
# Should this part of the check be enabled?
enabled: true
# Minimum server TPS needed for BadPackets to be active
minimumTps: 17.5
# Minimum elapsed time in milliseconds between a movement packet and a combat packet
minElapsedTime: 5
# Amount of suspicious combat packet situations before flagging
vlBeforeFlag: 3
# Aimbot check settings # Aimbot check settings
# Checks if the player is sending aimbot-like movements # Checks if the player is sending aimbot-like movements
aimbot: aimbot:
@@ -192,7 +216,7 @@ velocity:
# Should this check be enabled? # Should this check be enabled?
enabled: true enabled: true
# Minimum percentage of the given knockback a player has to meet # Minimum percentage of the given knockback a player has to meet
minimumPercentage: 98 minimumPercentage: 75
# Amount of low-velocity moments before flagging # Amount of low-velocity moments before flagging
vlBeforeFlag: 2 vlBeforeFlag: 2
+5 -1
View File
@@ -38,7 +38,11 @@ system:
# Minimum value is 1, default is 8 # Minimum value is 1, default is 8
# Example with 5: notifications after 5 vl, 10vl, 15vl, etc. # Example with 5: notifications after 5 vl, 10vl, 15vl, etc.
notify-every-vl: 8 notify-every-vl: 8
# Use /AntiCheatReloaded checks for a list of valid checks # Maximum distance a player can be set back
# If the last known valid location is further away than this,
# the player will be rubberbanded at their current location
# Minimum value is 5, default is 50
max-setback-distance: 50
disable-in: disable-in:
- example-world - example-world
- example-world-2 - example-world-2
+2 -2
View File
@@ -6,9 +6,9 @@ ALERT:
WARNING: WARNING:
- '&6&lACR &8>&7 You have been flagged for using cheats.' - '&6&lACR &8>&7 You have been flagged for using cheats.'
- '&6&lACR &8>&7 If you continue to cheat, action will be taken.' - '&6&lACR &8>&7 If you continue to cheat, action will be taken.'
BAN_REASON: '&6&lACR &8> &7Banned by AntiCheatReloaded' BAN_REASON: '&6&lACR &8> &7Banned for unfair advantage'
BAN_BROADCAST: '&6&lACR &8> &7%player% was banned for cheating' BAN_BROADCAST: '&6&lACR &8> &7%player% was banned for cheating'
KICK_REASON: '&6&lACR &8> &7Kicked for cheating' KICK_REASON: '&6&lACR &8> &7Kicked for unfair advantage'
KICK_BROADCAST: '&6&lACR &8> &7%player% was kicked for cheating' KICK_BROADCAST: '&6&lACR &8> &7%player% was kicked for cheating'
SPAM_WARNING: '&cStop spamming the server or you will be kicked!' SPAM_WARNING: '&cStop spamming the server or you will be kicked!'
SPAM_KICK_REASON: '&cKicked for spamming' SPAM_KICK_REASON: '&cKicked for spamming'
+4 -4
View File
@@ -1,9 +1,9 @@
# Time to exempt a player from moving because of entering/exiting a vehicle # Time to exempt a player from moving because of entering/exiting a vehicle
# Increase in case of false positives # Increase in case of false positives
ENTERED_EXITED_TIME: 1000 ENTERED_EXITED_TIME: 250
# Time to exempt a player from moving because of teleporting # Time to exempt a player from moving because of teleporting
# Increase in case of false positives # Increase in case of false positives
TELEPORT_TIME: 1000 TELEPORT_TIME: 1500
# Time to exempt a player from moving because of exiting fly mode # Time to exempt a player from moving because of exiting fly mode
# Changing this value is almost never required # Changing this value is almost never required
EXIT_FLY_TIME: 2000 EXIT_FLY_TIME: 2000
@@ -26,9 +26,9 @@ EXPLOSION_DAMAGE_TIME: 5000
# Amount of seconds to extend a players velocitized state after receiving velocity again # Amount of seconds to extend a players velocitized state after receiving velocity again
VELOCITY_EXTENSION: 2 VELOCITY_EXTENSION: 2
# Time a player is considered to have a change in velocity # Time a player is considered to have a change in velocity
VELOCITY_TIME: 2000 VELOCITY_TIME: 1000
# This is a set value and shouldn't be changed unless you know what you're doing # This is a set value and shouldn't be changed unless you know what you're doing
VELOCITY_PREVENT: 5000 VELOCITY_PREVENT: 2000
# This is a set value and shouldn't be changed unless you know what you're doing # This is a set value and shouldn't be changed unless you know what you're doing
VELOCITY_MAXTIMES: 2 VELOCITY_MAXTIMES: 2
# Minimum travel distance for move to be considered a teleport and subsequently be ignored # Minimum travel distance for move to be considered a teleport and subsequently be ignored
+4
View File
@@ -127,6 +127,9 @@ permissions:
anticheat.check.aimbot: anticheat.check.aimbot:
description: Allow players to use aimbot description: Allow players to use aimbot
default: false default: false
anticheat.check.aimbot:
description: Allow players to use strafe hacks
default: false
anticheat.check.exempt: anticheat.check.exempt:
description: Total exemption from checks description: Total exemption from checks
default: false default: false
@@ -158,3 +161,4 @@ permissions:
anticheat.check.illegalinteract: true anticheat.check.illegalinteract: true
anticheat.check.fastladder: true anticheat.check.fastladder: true
anticheat.check.aimbot: true anticheat.check.aimbot: true
anticheat.check.strafe: true