diff --git a/README.md b/README.md index 57a9a1b..f0e9f8a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ Lightweight, accurate anti-cheat for Paper 1.21.x +## Latest Updates (v1.1.2) + +- **reload**: `violation.decay_interval` changes now take effect immediately — the decay task is cancelled and recreated on every `/xac reload`. +- **NoFallCheck**: Added Beds (all 16 colour variants via `Tag.BEDS`) and Powder Snow to the list of blocks that cancel fall damage. Eliminates false positives when players land on these blocks. +- **config.yml**: Removed orphaned `allow_jump_crits` key from `checks.critical` section (was removed from code in v1.1.1). +- **JesusCheck, GlideCheck**: Eliminated `Math.sqrt()` from hot-path threshold comparisons. + ## 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.) diff --git a/pom.xml b/pom.xml index efd9411..6f75965 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.xeroth xeroanticheat - 1.1.1 + 1.1.2 jar XeroAntiCheat diff --git a/src/main/java/com/xeroth/xeroanticheat/XeroAntiCheat.java b/src/main/java/com/xeroth/xeroanticheat/XeroAntiCheat.java index 83e6a90..19ea3ac 100644 --- a/src/main/java/com/xeroth/xeroanticheat/XeroAntiCheat.java +++ b/src/main/java/com/xeroth/xeroanticheat/XeroAntiCheat.java @@ -44,6 +44,7 @@ public final class XeroAntiCheat extends JavaPlugin { private DatabaseManager databaseManager; private boolean protocolLibLoaded = false; + private org.bukkit.scheduler.BukkitTask decayTask; // Staff alert toggles private final Map alertToggles = new ConcurrentHashMap<>(); @@ -174,7 +175,7 @@ public final class XeroAntiCheat extends JavaPlugin { private void startDecayTask() { int interval = configManager.getInt("violation.decay_interval", 30) * 20; - Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> { + decayTask = Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> { violationManager.decayAll(); }, interval, interval); } @@ -233,6 +234,12 @@ public final class XeroAntiCheat extends JavaPlugin { violationManager.clearAll(); violationManager.setDecayRate( configManager.getDouble("violation.decay_rate", 0.5)); + + if (decayTask != null) { + decayTask.cancel(); + } + startDecayTask(); + getLogger().info("Configuration reloaded!"); } diff --git a/src/main/java/com/xeroth/xeroanticheat/checks/movement/GlideCheck.java b/src/main/java/com/xeroth/xeroanticheat/checks/movement/GlideCheck.java index b7b5d8e..4b1476a 100644 --- a/src/main/java/com/xeroth/xeroanticheat/checks/movement/GlideCheck.java +++ b/src/main/java/com/xeroth/xeroanticheat/checks/movement/GlideCheck.java @@ -37,11 +37,12 @@ public class GlideCheck extends Check { // Get velocity org.bukkit.util.Vector velocity = player.getVelocity(); - // Calculate horizontal speed - double horizontalSpeed = Math.sqrt(velocity.getX() * velocity.getX() + velocity.getZ() * velocity.getZ()); + // Calculate horizontal speed (squared to avoid Math.sqrt()) + double horizontalSpeedSq = velocity.getX() * velocity.getX() + velocity.getZ() * velocity.getZ(); // Check if moving fast horizontally - if (horizontalSpeed < minHorizontalSpeed) { + double minHorizSq = minHorizontalSpeed * minHorizontalSpeed; + if (horizontalSpeedSq < minHorizSq) { data.resetGlideTicks(); return; } diff --git a/src/main/java/com/xeroth/xeroanticheat/checks/movement/JesusCheck.java b/src/main/java/com/xeroth/xeroanticheat/checks/movement/JesusCheck.java index 0a52a52..3927df9 100644 --- a/src/main/java/com/xeroth/xeroanticheat/checks/movement/JesusCheck.java +++ b/src/main/java/com/xeroth/xeroanticheat/checks/movement/JesusCheck.java @@ -72,10 +72,10 @@ public class JesusCheck extends Check { if (current != null && last != null) { double dx = current.x() - last.x(); double dz = current.z() - last.z(); - double horizontalSpeed = Math.sqrt(dx * dx + dz * dz); + double horizontalSpeedSq = dx * dx + dz * dz; // If moving at reasonable speed on water, flag - if (horizontalSpeed > 0.1) { + if (horizontalSpeedSq > 0.01) { flag(data, player); } } diff --git a/src/main/java/com/xeroth/xeroanticheat/checks/movement/NoFallCheck.java b/src/main/java/com/xeroth/xeroanticheat/checks/movement/NoFallCheck.java index 90b82a9..921d6db 100644 --- a/src/main/java/com/xeroth/xeroanticheat/checks/movement/NoFallCheck.java +++ b/src/main/java/com/xeroth/xeroanticheat/checks/movement/NoFallCheck.java @@ -61,7 +61,9 @@ public class NoFallCheck extends Check { blockBelow == Material.HONEY_BLOCK || blockBelow == Material.HAY_BLOCK || blockBelow == Material.SLIME_BLOCK || - blockBelow == Material.COBWEB) { + blockBelow == Material.COBWEB || + blockBelow == Material.POWDER_SNOW || + org.bukkit.Tag.BEDS.isTagged(blockBelow)) { data.setLastExpectedFallDamage(0.0); return; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index bb14374..d9b15e0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -175,8 +175,6 @@ checks: # ---------------------------------------- critical: enabled: true - # Allow legitimate jump-crits - allow_jump_crits: true warn_vl: 10 kick_vl: 25 tempban_vl: 50 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7e739c9..9b5b9cc 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: XeroAntiCheat -version: 1.1.1 +version: 1.1.2 main: com.xeroth.xeroanticheat.XeroAntiCheat author: Xeroth description: Lightweight, accurate anti-cheat for Paper 1.21.x