v1.1.1: fix CriticalCheck dead code, optimize InventoryMoveCheck

This commit is contained in:
2026-03-15 12:26:28 -03:00
parent ac5a8e807b
commit 68e99adf3e
6 changed files with 17 additions and 29 deletions

View File

@@ -6,10 +6,10 @@ import com.xeroth.xeroanticheat.data.PlayerData;
import org.bukkit.entity.Player;
/**
* CriticalCheck - Detects critical hits when player is NOT in the air.
* CriticalCheck - Detects suspicious critical hits.
*
* Also detects if player is sprinting (criticals cancel sprint).
* Accounts for jump-crits (legitimate): allows if player was airborne in previous 3 ticks.
* Minecraft cancels sprint on critical hits. A hacked client can send both
* sprint and crit flags simultaneously.
*/
public class CriticalCheck extends Check {
@@ -40,28 +40,12 @@ public class CriticalCheck extends Check {
*/
public boolean checkCritical(Player player, PlayerData data, boolean isCritical) {
if (!isCritical) return false;
boolean allowJumpCrits = getConfigBoolean("allow_jump_crits", true);
// Get player state
boolean isOnGround = player.isOnGround();
double yVelocity = player.getVelocity().getY();
boolean wasAirborne = data.wasAirborne();
// If player is on ground and not moving up (no jump), flag
if (isOnGround && yVelocity <= 0.0) {
// Check if was recently airborne (jump-crit)
if (allowJumpCrits && wasAirborne) {
return false; // Legitimate jump-crit
}
return true; // Suspicious - no-air crit
}
// Check if sprinting (criticals cancel sprint)
// Crit while sprinting — Minecraft cancels sprint on crits
if (player.isSprinting()) {
return true; // Suspicious - crit while sprinting
return true;
}
return false;
}
}

View File

@@ -39,14 +39,14 @@ public class InventoryMoveCheck extends Check {
if (current == null || last == null) return;
// Calculate position change
// Calculate position change (squared to avoid Math.sqrt())
double dx = current.x() - last.x();
double dy = current.y() - last.y();
double dz = current.z() - last.z();
double distance = Math.sqrt(dx*dx + dy*dy + dz*dz);
double distanceSquared = dx*dx + dy*dy + dz*dz;
// If significant movement while inventory open, flag
if (distance > 0.1) {
if (distanceSquared > 0.01) {
flag(data, player);
}
}

View File

@@ -114,7 +114,6 @@ public class ConfigManager {
// Checks - Critical
DEFAULTS.put("checks.critical.enabled", true);
DEFAULTS.put("checks.critical.allow_jump_crits", true);
DEFAULTS.put("checks.critical.warn_vl", 10);
DEFAULTS.put("checks.critical.kick_vl", 25);
DEFAULTS.put("checks.critical.tempban_vl", 50);