v1.1.1: fix CriticalCheck dead code, optimize InventoryMoveCheck
This commit is contained in:
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
Lightweight, accurate anti-cheat for Paper 1.21.x
|
Lightweight, accurate anti-cheat for Paper 1.21.x
|
||||||
|
|
||||||
|
## Latest Updates (v1.1.1)
|
||||||
|
|
||||||
|
- **CriticalCheck**: Removed dead code — the "no-air crit" detection branch was logically unreachable because `isCritical=true` requires `!isOnGround`, making the subsequent `isOnGround` check always false. The check now only flags "crit while sprinting" (the only branch that could actually fire). Removed `allow_jump_crits` config key. (Future enhancement: Option B damage-ratio detection.)
|
||||||
|
- **InventoryMoveCheck**: Replaced `Math.sqrt()` with squared distance comparison (`distanceSquared > 0.01`), consistent with the ReachCheck optimisation.
|
||||||
|
|
||||||
## Latest Updates (v1.1.0)
|
## Latest Updates (v1.1.0)
|
||||||
|
|
||||||
- **ReachCheck**: Now measures distance to entity bounding box center instead of feet. Eliminates false negatives when attacking tall entities (horses, iron golems, withers). Also switched from `distance()` to `distanceSquared()` comparison, removing a `Math.sqrt()` from the hot path.
|
- **ReachCheck**: Now measures distance to entity bounding box center instead of feet. Eliminates false negatives when attacking tall entities (horses, iron golems, withers). Also switched from `distance()` to `distanceSquared()` comparison, removing a `Math.sqrt()` from the hot path.
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.xeroth</groupId>
|
<groupId>com.xeroth</groupId>
|
||||||
<artifactId>xeroanticheat</artifactId>
|
<artifactId>xeroanticheat</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>XeroAntiCheat</name>
|
<name>XeroAntiCheat</name>
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import com.xeroth.xeroanticheat.data.PlayerData;
|
|||||||
import org.bukkit.entity.Player;
|
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).
|
* Minecraft cancels sprint on critical hits. A hacked client can send both
|
||||||
* Accounts for jump-crits (legitimate): allows if player was airborne in previous 3 ticks.
|
* sprint and crit flags simultaneously.
|
||||||
*/
|
*/
|
||||||
public class CriticalCheck extends Check {
|
public class CriticalCheck extends Check {
|
||||||
|
|
||||||
@@ -41,25 +41,9 @@ public class CriticalCheck extends Check {
|
|||||||
public boolean checkCritical(Player player, PlayerData data, boolean isCritical) {
|
public boolean checkCritical(Player player, PlayerData data, boolean isCritical) {
|
||||||
if (!isCritical) return false;
|
if (!isCritical) return false;
|
||||||
|
|
||||||
boolean allowJumpCrits = getConfigBoolean("allow_jump_crits", true);
|
// Crit while sprinting — Minecraft cancels sprint on crits
|
||||||
|
|
||||||
// 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)
|
|
||||||
if (player.isSprinting()) {
|
if (player.isSprinting()) {
|
||||||
return true; // Suspicious - crit while sprinting
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ public class InventoryMoveCheck extends Check {
|
|||||||
|
|
||||||
if (current == null || last == null) return;
|
if (current == null || last == null) return;
|
||||||
|
|
||||||
// Calculate position change
|
// Calculate position change (squared to avoid Math.sqrt())
|
||||||
double dx = current.x() - last.x();
|
double dx = current.x() - last.x();
|
||||||
double dy = current.y() - last.y();
|
double dy = current.y() - last.y();
|
||||||
double dz = current.z() - last.z();
|
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 significant movement while inventory open, flag
|
||||||
if (distance > 0.1) {
|
if (distanceSquared > 0.01) {
|
||||||
flag(data, player);
|
flag(data, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ public class ConfigManager {
|
|||||||
|
|
||||||
// Checks - Critical
|
// Checks - Critical
|
||||||
DEFAULTS.put("checks.critical.enabled", true);
|
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.warn_vl", 10);
|
||||||
DEFAULTS.put("checks.critical.kick_vl", 25);
|
DEFAULTS.put("checks.critical.kick_vl", 25);
|
||||||
DEFAULTS.put("checks.critical.tempban_vl", 50);
|
DEFAULTS.put("checks.critical.tempban_vl", 50);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: XeroAntiCheat
|
name: XeroAntiCheat
|
||||||
version: 1.1.0
|
version: 1.1.1
|
||||||
main: com.xeroth.xeroanticheat.XeroAntiCheat
|
main: com.xeroth.xeroanticheat.XeroAntiCheat
|
||||||
author: Xeroth
|
author: Xeroth
|
||||||
description: Lightweight, accurate anti-cheat for Paper 1.21.x
|
description: Lightweight, accurate anti-cheat for Paper 1.21.x
|
||||||
|
|||||||
Reference in New Issue
Block a user