Completed work on #132, changes to Aimbot check

This commit is contained in:
Rammelkast committed 2021-10-24 10:46:51 +02:00
1 parent 058cf788fd
commit 5c596f5e2f
8 files changed
+41 -96

No files matched your search

@@ -525,27 +525,6 @@ public class Backend {
return isDoing(player, placedBlock, 0.1);
}
public void logDamage(final Player player, final int type) {
long time;
switch (type) {
case 1:
time = magic.DAMAGE_TIME();
break;
case 2:
time = magic.KNOCKBACK_DAMAGE_TIME();
break;
case 3:
time = magic.EXPLOSION_DAMAGE_TIME();
break;
default:
time = magic.DAMAGE_TIME();
break;
}
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + time);
// Only map in which termination time is calculated beforehand.
}
public void logEnterExit(final Player player) {
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME());
}
@@ -50,17 +50,17 @@ public final class AimbotCheck {
final float deltaPitch = movementManager.deltaPitch;
final float deltaYaw = movementManager.deltaYaw;
final float pitchAcceleration = Math.abs(deltaPitch - movementManager.lastDeltaPitch);
final float yawAcceleration = Math.abs(deltaYaw - movementManager.lastDeltaYaw);
if (deltaYaw > 3.0F && deltaPitch <= 10.0F && pitchAcceleration > 2.0F && yawAcceleration > 2.0F
&& deltaPitch < deltaYaw) {
final double gcd = Utilities.computeGcd(deltaPitch, movementManager.lastDeltaPitch);
final double mod = player.getLocation().getPitch() % gcd;
final double maxGcd = checksConfig.getDouble(CheckType.AIMBOT, "maxGcd");
final double maxMod = checksConfig.getDouble(CheckType.AIMBOT, "maxMod");
if (gcd < maxGcd || mod < maxMod) {
return new CheckResult(CheckResult.Result.FAILED, "failed computational check (gcd=" + gcd + ", mod=" + mod + ")");
}
final double gcd = Utilities.computeGcd(deltaPitch, movementManager.lastDeltaPitch);
final double mod = Math.abs(player.getLocation().getPitch() % gcd);
final double minAcceleration = checksConfig.getDouble(CheckType.AIMBOT, "minAcceleration");
final double maxMod = checksConfig.getDouble(CheckType.AIMBOT, "maxMod");
if (mod < maxMod && pitchAcceleration > minAcceleration
&& (deltaPitch == 0.0f || (deltaPitch > 45.0f && deltaYaw > 45.0f))) {
return new CheckResult(CheckResult.Result.FAILED,
"failed computational check (gcd=" + Utilities.roundDouble(gcd, 4) + ", mod="
+ Utilities.roundDouble(mod, 4) + ", accel=" + Utilities.roundDouble(pitchAcceleration, 4)
+ ")");
}
return PASS;
}
@@ -45,7 +45,7 @@ public final class FlightCheck {
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>();
public static final Map<UUID, Float> GRAVITY_VIOLATIONS = new HashMap<UUID, Float>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
private static final double GRAVITY_FRICTION = 0.9800000190734863D;
@@ -79,7 +79,7 @@ public final class FlightCheck {
// Start AirFlight
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks
&& !velocityTracker.isVelocitized() && movementManager.elytraEffectTicks <= 25) {
&& movementManager.elytraEffectTicks <= 25) {
// Config default base is 1200ms
// Ping clamped to max. 1000 to prevent spoofing for an advantage
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
@@ -89,7 +89,7 @@ public final class FlightCheck {
blockPlaceAccountingTime += checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
"accountForTpsDrops");
}
final long lastPlacedBlock = AntiCheatReloaded.getManager().getBackend().placedBlock
.containsKey(player.getUniqueId())
? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId())
@@ -100,12 +100,16 @@ public final class FlightCheck {
.isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation())) {
maxMotionY += 0.004D;
}
// Fixes water false positive
if (Utilities.isNearWater(player) || Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0))) {
if (Utilities.isNearWater(player)
|| Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0))) {
maxMotionY += 0.05;
}
// Velocity adjustment
maxMotionY += velocityTracker.getVertical();
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 1.25, 0))
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 0.75, 0))
@@ -136,8 +140,7 @@ public final class FlightCheck {
&& Math.round(movementManager.motionY * 1000) != 248
&& !(Math.round(movementManager.motionY * 1000) == 333
&& Math.round(movementManager.lastMotionY * 1000) != 333)
&& !velocityTracker.isVelocitized()
&& !player.hasPotionEffect(PotionEffectType.JUMP)
&& !velocityTracker.isVelocitized() && !player.hasPotionEffect(PotionEffectType.JUMP)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
&& (!Utilities.isNearBed(distance.getTo()) || ((Utilities.isNearBed(distance.getTo())
@@ -161,18 +164,16 @@ public final class FlightCheck {
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks
&& movementManager.lastMotionY < 0 && movementManager.motionY > 0
&& !velocityTracker.isVelocitized()
&& movementManager.elytraEffectTicks <= 25
&& movementManager.motionY > velocityTracker.getVertical() && movementManager.elytraEffectTicks <= 25
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
&& !(Math.round(movementManager.motionY * 1000) == 396) && movementManager.airTicks == 15) {
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
}
if (movementManager.airTicks >= minAirTicks && movementManager.motionY > 0
&& velocityTracker.getVertical() <= 0.0D && movementManager.slimeInfluenceTicks <= 0
&& movementManager.elytraEffectTicks <= 25
if (movementManager.airTicks >= minAirTicks && movementManager.motionY > 0 && !velocityTracker.isVelocitized()
&& movementManager.slimeInfluenceTicks <= 0 && movementManager.elytraEffectTicks <= 25
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) {
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
@@ -192,7 +193,7 @@ public final class FlightCheck {
// Start Gravity
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "gravity") && !movementManager.onGround
&& movementManager.motionY < 0 && !velocityTracker.isVelocitized()
&& movementManager.motionY < 0 && Math.abs(movementManager.motionY) > velocityTracker.getVertical()
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
&& !Utilities.isNearWeb(player) && movementManager.elytraEffectTicks <= 25
@@ -184,7 +184,7 @@ public final class SpeedCheck {
}
// Adjust for velocity
predict += velocityTracker.getHorizontal() * 0.8D;
limit += velocityTracker.getHorizontal();
if (distanceXZ - predict > limit) {
return new CheckResult(CheckResult.Result.FAILED, "AirSpeed",
@@ -233,7 +233,7 @@ public final class SpeedCheck {
}
// Add velocity
limit += velocityTracker.getHorizontal() * 0.8D;
limit += velocityTracker.getHorizontal();
if (initialAcceleration > limit) {
return new CheckResult(CheckResult.Result.FAILED, "AirAcceleration",
@@ -339,6 +339,9 @@ public final class SpeedCheck {
if (movementManager.sneakingTicks > 1) {
limit *= 0.68D;
}
// Velocity adjustment
limit += velocityTracker.getHorizontal();
if (distanceXZ - limit > 0) {
return new CheckResult(CheckResult.Result.FAILED, "GroundSpeed",
@@ -357,8 +360,10 @@ public final class SpeedCheck {
return PASS;
}
final MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager()
.getUser(player.getUniqueId()).getMovementManager();
final User user = AntiCheatReloaded.getManager().getUserManager()
.getUser(player.getUniqueId());
final MovementManager movementManager = user.getMovementManager();
final VelocityTracker velocityTracker = user.getVelocityTracker();
// Riptiding exemption
if (movementManager.riptideTicks > 0) {
return PASS;
@@ -378,6 +383,9 @@ public final class SpeedCheck {
if (movementManager.nearLiquidTicks > 6) {
maxMotionY *= 1.0525D;
}
// Adjust for velocity
maxMotionY += velocityTracker.getVertical();
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) {
return new CheckResult(CheckResult.Result.FAILED, "VerticalSpeed",
@@ -50,18 +50,6 @@ public interface Magic {
* Time to exempt a player from moving because of joining the server; Type=SYSTEM, Leniency=INCREASE.
*/
public int JOIN_TIME();
/**
* Time to exempt a player from moving because of taking damage; Type=SYSTEM, Leniency=INCREASE.
*/
public int DAMAGE_TIME();
/**
* Time to exempt a player from moving because of taking damage with knockback effects; Type=SYSTEM, Leniency=INCREASE.
*/
public int KNOCKBACK_DAMAGE_TIME();
/**
* Time to exempt a player from moving because of taking damage from an explosion; Type=SYSTEM, Leniency=INCREASE.
*/
public int EXPLOSION_DAMAGE_TIME();
/**
* Time a player is considered to have a change in velocity; Type=SYSTEM, Leniency=INCREASE.
*/
@@ -19,10 +19,7 @@
package com.rammelkast.anticheatreloaded.event;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@@ -39,7 +36,6 @@ import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.CriticalsCheck;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class EntityListener extends EventListener {
@@ -114,21 +110,6 @@ public class EntityListener extends EventListener {
log(result.getMessage(), (Player)e.getDamager(), CheckType.AIMBOT, result.getSubCheck());
}
}
}
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (e.getDamager() instanceof Player) {
Player p = (Player) e.getDamager();
getBackend().logDamage(p, 1);
int value = VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
getBackend().logDamage(player, value);
} else {
if (e.getDamager() instanceof TNTPrimed || e.getDamager() instanceof Creeper) {
getBackend().logDamage(player, 3);
} else {
getBackend().logDamage(player, 1);
}
}
}
if (e.getDamager() instanceof Player && event.getCause() == DamageCause.ENTITY_ATTACK) {
Player player = (Player) e.getDamager();
+3 -3
View File
@@ -193,10 +193,10 @@ killaura:
aimbot:
# Should this check be enabled?
enabled: true
# Maximum gcd value for check to consider aim illegal
maxGcd: 0.002
# Maximum pitch acceleration for check to consider aim illegal
minAcceleration: 0.5
# Maximum mod value for check to consider aim illegal
maxMod: 0.003
maxMod: 0.0001
# Criticals check settings
# Checks if the player tries to do a crit without needed conditions
criticals:
-12
View File
@@ -8,18 +8,6 @@ TELEPORT_TIME: 1500
# If your server is slow when a player joins, increasing this value is important
# Shouldn't be lower than 1500 or higher than 5000
JOIN_TIME: 2000
# Time to exempt a player from moving because of taking damage
# Can be decreased very slightly to increase detection
# Increase in case of false positives after taking damage
DAMAGE_TIME: 500
# Time to exempt a player from moving because of taking damage with knockback effects
# Can be decreased very slightly to increase detection
# Increase in case of false positives after knockback
KNOCKBACK_DAMAGE_TIME: 2000
# Time to exempt a player from moving because of taking damage from an explosion
# Can be decreased very slightly to increase detection
# Increasing in case of false positives after explosions
EXPLOSION_DAMAGE_TIME: 2500
# Time a player is considered to have a change in velocity
VELOCITY_TIME: 1500
# Minimum travel distance for move to be considered a teleport and subsequently be ignored