Files
XeroAntiCheat/src/main/java/com/xeroth/xeroanticheat/manager/MetricsManager.java
Axel 112a61cf0c 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
2026-03-15 13:17:28 -03:00

52 lines
1.3 KiB
Java

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();
}
}