v1.2.0: Implement improvement plan features

- Setback System: Teleports flagged players to lastSafeLocation (opt-in per check)
- TPS Lag Compensation: isServerLagging() helper, guards in Fly/Spider/Glide checks
- Universal Buffer System: Buffer fields for Jesus/Reach/KillAura/Timer/FastPlace/Scaffold/FastEat
- /xac debug command: Shows check-specific debug info for players
- Public API: XACApi with isFlagged(), getViolationLevel(), getTotalViolations(), isBypassed()
- Performance Metrics: /xac stats command with checks/flags/punishments tracking
This commit is contained in:
2026-03-15 13:17:28 -03:00
parent a4a87e62de
commit 112a61cf0c
23 changed files with 387 additions and 16 deletions

View File

@@ -47,6 +47,7 @@ public class CheckManager {
public void runCheck(String checkName, PlayerData data, Player player) {
Check check = checksByName.get(checkName.toLowerCase());
if (check != null && check.isEnabled()) {
plugin.getMetricsManager().recordCheck();
check.check(data, player);
}
}

View File

@@ -0,0 +1,51 @@
package com.xeroth.xeroanticheat.manager;
import java.util.concurrent.atomic.AtomicLong;
public class MetricsManager {
private final AtomicLong totalChecksRun = new AtomicLong();
private final AtomicLong totalFlagsIssued = new AtomicLong();
private final AtomicLong totalPunishments = new AtomicLong();
private long startTimeMs = System.currentTimeMillis();
public void recordCheck() {
totalChecksRun.incrementAndGet();
}
public void recordFlag() {
totalFlagsIssued.incrementAndGet();
}
public void recordPunishment() {
totalPunishments.incrementAndGet();
}
public long getTotalChecks() {
return totalChecksRun.get();
}
public long getTotalFlags() {
return totalFlagsIssued.get();
}
public long getTotalPunishments() {
return totalPunishments.get();
}
public long getUptimeSeconds() {
return (System.currentTimeMillis() - startTimeMs) / 1000;
}
public double getChecksPerSecond() {
long uptime = getUptimeSeconds();
return uptime > 0 ? (double) totalChecksRun.get() / uptime : 0;
}
public void reset() {
totalChecksRun.set(0);
totalFlagsIssued.set(0);
totalPunishments.set(0);
startTimeMs = System.currentTimeMillis();
}
}

View File

@@ -123,6 +123,7 @@ public class PunishmentManager {
kickCmd = kickCmd.replace("%player%", playerName).replace("%reason%", reason);
executeCommand(kickCmd);
logPunishment(type, player, checkName, vl);
plugin.getMetricsManager().recordPunishment();
}
case "TEMPBAN" -> {
String tempbanCmd = plugin.getConfigManager().getString("punishments.tempban_command",
@@ -130,6 +131,7 @@ public class PunishmentManager {
tempbanCmd = tempbanCmd.replace("%player%", playerName).replace("%reason%", reason);
executeCommand(tempbanCmd);
logPunishment(type, player, checkName, vl);
plugin.getMetricsManager().recordPunishment();
}
case "PERMBAN" -> {
String permbanCmd = plugin.getConfigManager().getString("punishments.permban_command",
@@ -137,6 +139,7 @@ public class PunishmentManager {
permbanCmd = permbanCmd.replace("%player%", playerName).replace("%reason%", reason);
executeCommand(permbanCmd);
logPunishment(type, player, checkName, vl);
plugin.getMetricsManager().recordPunishment();
}
}
}

View File

@@ -83,6 +83,8 @@ public class ViolationManager {
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().info(player.getName() + " violated " + checkName + " (VL: " + newVl + ")");
}
plugin.getMetricsManager().recordFlag();
}
/**