Fix #123, fix elytrafly false positive, fix flight false positive when falling, fix speed false positive with slabs, fixed strafe false positive with slabs, fixed TPS formatting issue, improved default config

This commit is contained in:
Rammelkast committed 2020-11-25 11:43:49 +01:00
1 parent 646e906ada
commit bd1db83a98
8 files changed
+46 -72

No files matched your search

@@ -71,9 +71,11 @@ public class ElytraCheck {
}
if (!JUMP_Y_VALUE.containsKey(uuid)) {
JUMP_Y_VALUE.put(uuid, distance.toY());
// Distance + player height
JUMP_Y_VALUE.put(uuid, distance.toY() + 1.8D);
return PASS;
}
double lastY = JUMP_Y_VALUE.get(uuid);
if (lastY < distance.toY()) {
double diff = distance.toY() - lastY;
@@ -104,7 +104,7 @@ public class FlightCheck {
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) < 5E-3
if (Math.abs(movementManager.motionY - movementManager.lastMotionY) < (movementManager.airTicks >= 115 ? 1E-3 : 5E-3)
&& !Utilities.couldBeOnBoat(player)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
@@ -61,6 +61,9 @@ public class SpeedCheck {
&& movementManager.elytraEffectTicks <= 0 && !Utilities.isNearClimbable(player)) {
double multiplier = 0.985D;
double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1);
// Prevents false when falling from great heights
if (movementManager.airTicks >= 115)
predict = Math.max(0.08, predict);
double limit = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "baseLimit"); // Default 0.03125
// Adjust for ice
if (movementManager.iceInfluenceTicks > 0) {
@@ -148,7 +151,7 @@ public class SpeedCheck {
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
// Adjust for slabs
if (movementManager.halfMovementHistoryCounter > 15)
limit *= 2.0D;
limit *= 2.05D;
// Adjust for custom walking speed
double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airAcceleration",
"walkSpeedMultiplier"); // Default 1.4
@@ -165,7 +168,8 @@ public class SpeedCheck {
// JumpBehaviour
// Works against YPorts and mini jumps
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "jumpBehaviour") && movementManager.touchedGroundThisTick
&& !boxedIn && movementManager.slimeInfluenceTicks <= 10) {
&& !boxedIn && movementManager.slimeInfluenceTicks <= 10 && !Utilities.isNearHalfblock(movingTowards)
&& !Utilities.isNearHalfblock(movingTowards.clone().subtract(0, 0.51, 0))) {
// This happens naturally
if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) {
double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default
@@ -202,10 +206,11 @@ 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;
// Other speed increasing effects (idk why, bloody Bukkt..)
if (movementManager.hasIncreasingEffect && movementManager.groundTicks > 3)
limit *= 1.12D;
if (movementManager.hadIncreasingEffect && !movementManager.hasIncreasingEffect)
limit *= 1.08D;
if (movementManager.iceInfluenceTicks >= 50) {
// When moving off ice
if (!Utilities.couldBeOnIce(movingTowards))
@@ -44,7 +44,7 @@ public class StrafeCheck {
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) || VersionUtil.isFlying(player) || player.isDead()
|| Utilities.isHalfblock(to.getBlock().getRelative(BlockFace.DOWN)))
|| Utilities.isHalfblock(to.getBlock().getRelative(BlockFace.DOWN)) || Utilities.isNearHalfblock(to))
return PASS;
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
@@ -19,8 +19,10 @@
package com.rammelkast.anticheatreloaded.event;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
@@ -47,6 +49,11 @@ public class EventListener implements Listener {
private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
private static final DecimalFormat TPS_FORMAT = new DecimalFormat("##.##");
static {
// What the hell, Java..
TPS_FORMAT.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));
}
public static void log(String message, Player player, CheckType type, String subcheck) {
User user = getUserManager().getUser(player.getUniqueId());
if (user == null)
@@ -89,14 +89,10 @@ 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;
// If the player has a speed increasing effect
public boolean hasIncreasingEffect = false;
// If the player had a speed increasing effect previous tick
public boolean hadIncreasingEffect = false;
// Time of last update
public long lastUpdate;
@@ -189,11 +185,8 @@ 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);
this.hadIncreasingEffect = this.hasIncreasingEffect;
this.hasIncreasingEffect = !player.getActivePotionEffects().isEmpty();
double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference()
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference());