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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ public class ViolationManager {
|
||||
if (plugin.getConfigManager().isDebug()) {
|
||||
plugin.getLogger().info(player.getName() + " violated " + checkName + " (VL: " + newVl + ")");
|
||||
}
|
||||
|
||||
plugin.getMetricsManager().recordFlag();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user