Add config-driven AssetProbe (TEXTURES/FONT/CORRUPTION), ProbeFreezeManager, and DiscordWebhookNotifier

This commit is contained in:
notme_ssa committed 2026-11-29 20:51:11 +07:00
1 parent d66f60533e
commit ca21fe1a5d
11 files changed
+673 -37

No files matched your search

+6 -3
View File
@@ -29,10 +29,12 @@
- **Phase 1**: 1.20.6 vanilla edge keys (`item.minecraft.mace`) + nested mod `translate`/`keybind` inside `chat.type.text` `with` arguments. - **Phase 1**: 1.20.6 vanilla edge keys (`item.minecraft.mace`) + nested mod `translate`/`keybind` inside `chat.type.text` `with` arguments.
- **Phase 2**: pushes a temporary server resource pack overriding mod keys (`key.meteor-client.open-gui`, `category.meteor-client`) and placing custom keys inside mod namespaces (`assets/meteor-client/lang/`, `assets/opsec/lang/`). - **Phase 2**: pushes a temporary server resource pack overriding mod keys (`key.meteor-client.open-gui`, `category.meteor-client`) and placing custom keys inside mod namespaces (`assets/meteor-client/lang/`, `assets/opsec/lang/`).
- **Phase 3**: calls `removeResourcePack`, waits 80 ticks (4s) for clean client reload, and verifies cache eviction. - **Phase 3**: calls `removeResourcePack`, waits 80 ticks (4s) for clean client reload, and verifies cache eviction.
- **Differential Bitmap Font Asset Probe (`AssetProbeLabManager`)**: - **Differential Bitmap Font Asset Probe (`AssetProbeListener` & `AssetProbeLabManager`)**:
- Runs an A/B control pack (`0_CONTROL_MISSING_BITMAP` pointing at a guaranteed missing PNG -> `FAILED_RELOAD`) against real mod texture paths (e.g. `meteor-client:meteor.png` -> `assets/meteor-client/textures/meteor.png`). - Config-driven `TEXTURES`, `FONT`, and `CORRUPTION` resource-pack rules (`asset-probe.rules`) with automatic A/B control pack verification (`FAILED_RELOAD` on guaranteed missing asset vs `SUCCESSFULLY_LOADED` on real mod texture paths like `meteor-client:meteor.png`).
- On Vanilla, missing mod textures return `FAILED_RELOAD`; on modded clients (even with OpSec Key Spoof active), existing mod JAR textures load cleanly and return `SUCCESSFULLY_LOADED`. - Works directly through `FontManager` / `ResourceManager`, detecting modded clients even when OpSec Key Spoof is active.
- **Command-Book Verification Probe (`CommandBookProbeManager`)**: declares a synthetic command node (`/asverify_<nonce>`) via `WrapperPlayServerDeclareCommands` and opens a verification Written Book with `ClickEvent(RUN_COMMAND)` to test for client-side command-book blockers. - **Command-Book Verification Probe (`CommandBookProbeManager`)**: declares a synthetic command node (`/asverify_<nonce>`) via `WrapperPlayServerDeclareCommands` and opens a verification Written Book with `ClickEvent(RUN_COMMAND)` to test for client-side command-book blockers.
- **Probe Freeze (`ProbeFreezeManager`)**: optionally freezes movement, block/entity actions, and non-whitelisted commands (`probe-freeze.allowed-commands` regex) until verification probes finish or the safety timeout expires.
- **Discord Webhook Alerts (`DiscordWebhookNotifier`)**: async rate-limited JSON embed webhook notifier (strictly opt-in via `discord.enabled` + `discord.webhook-url`).
- **Additional Subsystems**: `IdentityLinkerManager` (HTTP cache alt-linking), `ResourcePackIntegrityListener` (`ACCEPTED -> SUCCESSFULLY_LOADED < 5ms` timing anomaly check), `ProxyDetectionManager` (RTT delta heuristic), `OsDetectorService` / `OsFingerprintManager` (passive TCP/OS fingerprinting), `ActiveReconScanner`, and `ClientApiHookManager` (Lunar, Badlion, Feather, LabyMod, Bedrock/Geyser). - **Additional Subsystems**: `IdentityLinkerManager` (HTTP cache alt-linking), `ResourcePackIntegrityListener` (`ACCEPTED -> SUCCESSFULLY_LOADED < 5ms` timing anomaly check), `ProxyDetectionManager` (RTT delta heuristic), `OsDetectorService` / `OsFingerprintManager` (passive TCP/OS fingerprinting), `ActiveReconScanner`, and `ClientApiHookManager` (Lunar, Badlion, Feather, LabyMod, Bedrock/Geyser).
### 3. Detection Logic ### 3. Detection Logic
@@ -50,6 +52,7 @@ AntiSpoofPlugin.flagPlayer(player, violationType, reason)
├─ Record violation on PlayerProfile & increment weighted threat level ├─ Record violation on PlayerProfile & increment weighted threat level
├─ PlayerLogManager -> append structured FLAG entry + JSON snapshot ├─ PlayerLogManager -> append structured FLAG entry + JSON snapshot
├─ notifyStaff -> broadcast formatted alert to online staff (antispoof.alerts) ├─ notifyStaff -> broadcast formatted alert to online staff (antispoof.alerts)
├─ DiscordWebhookNotifier -> async rate-limited JSON embed (if discord.enabled)
├─ EventBus -> AntiSpoofAPI dispatches ViolationReportedEvent ├─ EventBus -> AntiSpoofAPI dispatches ViolationReportedEvent
└─ If PunishmentRule.isPunish() && !commands.isEmpty(): └─ If PunishmentRule.isPunish() && !commands.isEmpty():
├─ Dispatch AntiSpoofPrePunishmentEvent (cancellable) ├─ Dispatch AntiSpoofPrePunishmentEvent (cancellable)
@@ -431,6 +431,9 @@ public final class AntiSpoofCommand implements CommandExecutor, TabCompleter {
return; return;
} }
plugin.getConfigManager().reload(); plugin.getConfigManager().reload();
if (plugin.getProbeFreezeManager() != null) {
plugin.getProbeFreezeManager().reloadPatterns();
}
send(sender, "%prefix% &aConfiguration reloaded cleanly."); send(sender, "%prefix% &aConfiguration reloaded cleanly.");
} }
@@ -98,6 +98,11 @@ public final class ConfigManager {
private boolean keySpoofProbeEnabled = true; private boolean keySpoofProbeEnabled = true;
private boolean keySpoofProbeRequirePack = true; private boolean keySpoofProbeRequirePack = true;
// Probe freeze (locks movement/actions/commands while probes run)
private boolean probeFreezeEnabled;
private int probeFreezeTimeoutSeconds = 15;
private List<String> probeFreezeAllowedCommands = List.of("^/(login|register|l|reg)(\\s.*)?$");
// Proxy detection & TCP/OS fingerprinting // Proxy detection & TCP/OS fingerprinting
private boolean proxyDetectionEnabled; private boolean proxyDetectionEnabled;
private int proxyMinSamples = 5; private int proxyMinSamples = 5;
@@ -213,6 +218,13 @@ public final class ConfigManager {
keySpoofProbeEnabled = config.getBoolean("key-spoof-probe.enabled", true); keySpoofProbeEnabled = config.getBoolean("key-spoof-probe.enabled", true);
keySpoofProbeRequirePack = config.getBoolean("key-spoof-probe.require-pack", true); keySpoofProbeRequirePack = config.getBoolean("key-spoof-probe.require-pack", true);
probeFreezeEnabled = config.getBoolean("probe-freeze.enabled", false);
probeFreezeTimeoutSeconds = Math.max(3, config.getInt("probe-freeze.timeout-seconds", 15));
List<String> freezeCmds = config.getStringList("probe-freeze.allowed-commands");
probeFreezeAllowedCommands = freezeCmds.isEmpty()
? List.of("^/(login|register|l|reg)(\\s.*)?$")
: List.copyOf(freezeCmds);
proxyDetectionEnabled = config.getBoolean("proxy-detection.enabled", true); proxyDetectionEnabled = config.getBoolean("proxy-detection.enabled", true);
proxyMinSamples = Math.max(1, config.getInt("proxy-detection.min-samples", 5)); proxyMinSamples = Math.max(1, config.getInt("proxy-detection.min-samples", 5));
proxySampleWindow = Math.max(proxyMinSamples, config.getInt("proxy-detection.sample-window", 10)); proxySampleWindow = Math.max(proxyMinSamples, config.getInt("proxy-detection.sample-window", 10));
@@ -546,6 +558,9 @@ public final class ConfigManager {
public boolean isAssetProbeEnabled() { return assetProbeEnabled; } public boolean isAssetProbeEnabled() { return assetProbeEnabled; }
public boolean isKeySpoofProbeEnabled() { return keySpoofProbeEnabled; } public boolean isKeySpoofProbeEnabled() { return keySpoofProbeEnabled; }
public boolean isKeySpoofProbeRequirePack() { return keySpoofProbeRequirePack; } public boolean isKeySpoofProbeRequirePack() { return keySpoofProbeRequirePack; }
public boolean isProbeFreezeEnabled() { return probeFreezeEnabled; }
public int getProbeFreezeTimeoutSeconds() { return probeFreezeTimeoutSeconds; }
public List<String> getProbeFreezeAllowedCommands() { return probeFreezeAllowedCommands; }
public boolean isProxyDetectionEnabled() { return proxyDetectionEnabled; } public boolean isProxyDetectionEnabled() { return proxyDetectionEnabled; }
public int getProxyMinSamples() { return proxyMinSamples; } public int getProxyMinSamples() { return proxyMinSamples; }
@@ -19,6 +19,7 @@ import com.gigazelensky.antispoof.fingerprint.OsFingerprintManager;
import com.gigazelensky.antispoof.gui.GuiListener; import com.gigazelensky.antispoof.gui.GuiListener;
import com.gigazelensky.antispoof.hook.AntiSpoofPlaceholderExpansion; import com.gigazelensky.antispoof.hook.AntiSpoofPlaceholderExpansion;
import com.gigazelensky.antispoof.hook.ClientApiHookManager; import com.gigazelensky.antispoof.hook.ClientApiHookManager;
import com.gigazelensky.antispoof.hook.DiscordWebhookNotifier;
import com.gigazelensky.antispoof.hook.PlaceholderFormatter; import com.gigazelensky.antispoof.hook.PlaceholderFormatter;
import com.gigazelensky.antispoof.packet.BrandChannelListener; import com.gigazelensky.antispoof.packet.BrandChannelListener;
import com.gigazelensky.antispoof.probe.ActiveReconScanner; import com.gigazelensky.antispoof.probe.ActiveReconScanner;
@@ -27,6 +28,7 @@ import com.gigazelensky.antispoof.probe.AssetProbeListener;
import com.gigazelensky.antispoof.probe.CommandBookProbeManager; import com.gigazelensky.antispoof.probe.CommandBookProbeManager;
import com.gigazelensky.antispoof.probe.IdentityLinkerManager; import com.gigazelensky.antispoof.probe.IdentityLinkerManager;
import com.gigazelensky.antispoof.probe.KeySpoofRpProbeManager; import com.gigazelensky.antispoof.probe.KeySpoofRpProbeManager;
import com.gigazelensky.antispoof.probe.ProbeFreezeManager;
import com.gigazelensky.antispoof.probe.ProbeHttpServer; import com.gigazelensky.antispoof.probe.ProbeHttpServer;
import com.gigazelensky.antispoof.probe.ProxyDetectionManager; import com.gigazelensky.antispoof.probe.ProxyDetectionManager;
import com.gigazelensky.antispoof.probe.ResourcePackIntegrityListener; import com.gigazelensky.antispoof.probe.ResourcePackIntegrityListener;
@@ -82,11 +84,13 @@ public final class AntiSpoofPlugin extends JavaPlugin {
private ResourcePackIntegrityListener resourcePackIntegrityListener; private ResourcePackIntegrityListener resourcePackIntegrityListener;
private TranslationProbeManager translationProbeManager; private TranslationProbeManager translationProbeManager;
private KeySpoofRpProbeManager keySpoofRpProbeManager; private KeySpoofRpProbeManager keySpoofRpProbeManager;
private ProbeFreezeManager probeFreezeManager;
private CommandBookProbeManager commandBookProbeManager; private CommandBookProbeManager commandBookProbeManager;
private ProxyDetectionManager proxyDetectionManager; private ProxyDetectionManager proxyDetectionManager;
private ActiveReconScanner activeReconScanner; private ActiveReconScanner activeReconScanner;
private BrandChannelListener brandChannelListener; private BrandChannelListener brandChannelListener;
private ClientApiHookManager clientApiHookManager; private ClientApiHookManager clientApiHookManager;
private DiscordWebhookNotifier discordWebhookNotifier;
public static AntiSpoofPlugin getInstance() { public static AntiSpoofPlugin getInstance() {
return instance; return instance;
@@ -135,18 +139,22 @@ public final class AntiSpoofPlugin extends JavaPlugin {
this.resourcePackIntegrityListener = new ResourcePackIntegrityListener(this); this.resourcePackIntegrityListener = new ResourcePackIntegrityListener(this);
this.translationProbeManager = new TranslationProbeManager(this); this.translationProbeManager = new TranslationProbeManager(this);
this.keySpoofRpProbeManager = new KeySpoofRpProbeManager(this, probeHttpServer); this.keySpoofRpProbeManager = new KeySpoofRpProbeManager(this, probeHttpServer);
this.probeFreezeManager = new ProbeFreezeManager(this);
this.commandBookProbeManager = new CommandBookProbeManager(this); this.commandBookProbeManager = new CommandBookProbeManager(this);
this.commandBookProbeManager.start(); this.commandBookProbeManager.start();
this.proxyDetectionManager = new ProxyDetectionManager(this); this.proxyDetectionManager = new ProxyDetectionManager(this);
this.activeReconScanner = new ActiveReconScanner(this); this.activeReconScanner = new ActiveReconScanner(this);
this.brandChannelListener = new BrandChannelListener(this); this.brandChannelListener = new BrandChannelListener(this);
this.clientApiHookManager = new ClientApiHookManager(this); this.clientApiHookManager = new ClientApiHookManager(this);
this.discordWebhookNotifier = new DiscordWebhookNotifier(this);
this.discordWebhookNotifier.start();
// 5. Register Bukkit Listeners // 5. Register Bukkit Listeners
PluginManager pm = getServer().getPluginManager(); PluginManager pm = getServer().getPluginManager();
pm.registerEvents(brandChannelListener, this); pm.registerEvents(brandChannelListener, this);
pm.registerEvents(translationProbeManager, this); pm.registerEvents(translationProbeManager, this);
pm.registerEvents(keySpoofRpProbeManager, this); pm.registerEvents(keySpoofRpProbeManager, this);
pm.registerEvents(probeFreezeManager, this);
pm.registerEvents(identityLinkerManager, this); pm.registerEvents(identityLinkerManager, this);
pm.registerEvents(assetProbeListener, this); pm.registerEvents(assetProbeListener, this);
pm.registerEvents(assetProbeLabManager, this); pm.registerEvents(assetProbeLabManager, this);
@@ -212,7 +220,10 @@ public final class AntiSpoofPlugin extends JavaPlugin {
} }
if (keySpoofRpProbeManager != null) keySpoofRpProbeManager.shutdown(); if (keySpoofRpProbeManager != null) keySpoofRpProbeManager.shutdown();
if (probeFreezeManager != null) probeFreezeManager.shutdown();
if (assetProbeListener != null) assetProbeListener.shutdown();
if (assetProbeLabManager != null) assetProbeLabManager.shutdown(); if (assetProbeLabManager != null) assetProbeLabManager.shutdown();
if (discordWebhookNotifier != null) discordWebhookNotifier.shutdown();
if (translationProbeManager != null) translationProbeManager.shutdown(); if (translationProbeManager != null) translationProbeManager.shutdown();
if (commandBookProbeManager != null) commandBookProbeManager.shutdown(); if (commandBookProbeManager != null) commandBookProbeManager.shutdown();
if (identityLinkerManager != null) identityLinkerManager.shutdown(); if (identityLinkerManager != null) identityLinkerManager.shutdown();
@@ -251,10 +262,13 @@ public final class AntiSpoofPlugin extends JavaPlugin {
playerLogManager.log(player, LogType.FLAG, "[" + violationType + "] " + reason + " (threat=" + newThreat + ")"); playerLogManager.log(player, LogType.FLAG, "[" + violationType + "] " + reason + " (threat=" + newThreat + ")");
notifyStaff(player, violationType, reason); notifyStaff(player, violationType, reason);
PunishmentRule rule = ruleForViolation(violationType);
if (discordWebhookNotifier != null && configManager.isDiscordEnabled() && (rule == null || rule.isDiscordAlert())) {
discordWebhookNotifier.sendAlert(player, violationType, reason, newThreat);
}
eventBus.publish(new ViolationReportedEvent(player, violationType, reason, brand)); eventBus.publish(new ViolationReportedEvent(player, violationType, reason, brand));
// Execute configured punishments if rule enables punishment // Execute configured punishments if rule enables punishment
PunishmentRule rule = ruleForViolation(violationType);
if (rule != null && rule.isPunish() && !rule.getCommands().isEmpty()) { if (rule != null && rule.isPunish() && !rule.getCommands().isEmpty()) {
executePunishment(player, violationType, reason, brand, null, rule.getCommands(), newThreat); executePunishment(player, violationType, reason, brand, null, rule.getCommands(), newThreat);
} }
@@ -264,7 +278,7 @@ public final class AntiSpoofPlugin extends JavaPlugin {
flagPlayer(player, ViolationType.EXTERNAL_REPORT, "[" + sourcePlugin + "] " + reason); flagPlayer(player, ViolationType.EXTERNAL_REPORT, "[" + sourcePlugin + "] " + reason);
} }
private void executePunishment( public void executePunishment(
Player player, Player player,
String violationType, String violationType,
String reason, String reason,
@@ -445,6 +459,8 @@ public final class AntiSpoofPlugin extends JavaPlugin {
public AssetProbeLabManager getAssetProbeLabManager() { return assetProbeLabManager; } public AssetProbeLabManager getAssetProbeLabManager() { return assetProbeLabManager; }
public TranslationProbeManager getTranslationProbeManager() { return translationProbeManager; } public TranslationProbeManager getTranslationProbeManager() { return translationProbeManager; }
public KeySpoofRpProbeManager getKeySpoofRpProbeManager() { return keySpoofRpProbeManager; } public KeySpoofRpProbeManager getKeySpoofRpProbeManager() { return keySpoofRpProbeManager; }
public ProbeFreezeManager getProbeFreezeManager() { return probeFreezeManager; }
public DiscordWebhookNotifier getDiscordWebhookNotifier() { return discordWebhookNotifier; }
public CommandBookProbeManager getCommandBookProbeManager() { return commandBookProbeManager; } public CommandBookProbeManager getCommandBookProbeManager() { return commandBookProbeManager; }
public ProxyDetectionManager getProxyDetectionManager() { return proxyDetectionManager; } public ProxyDetectionManager getProxyDetectionManager() { return proxyDetectionManager; }
public ActiveReconScanner getActiveReconScanner() { return activeReconScanner; } public ActiveReconScanner getActiveReconScanner() { return activeReconScanner; }
@@ -0,0 +1,158 @@
package com.gigazelensky.antispoof.hook;
import com.gigazelensky.antispoof.core.AntiSpoofPlugin;
import com.gigazelensky.antispoof.data.OsInfo;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import org.bukkit.entity.Player;
/**
* Async rate-limited Discord webhook embed notifier.
* Strictly opt-in: does nothing unless `discord.enabled: true` and a valid webhook URL is configured.
*/
public final class DiscordWebhookNotifier {
private static final int MAX_QUEUE = 128;
private static final long MIN_INTERVAL_MS = 1_100L;
private final AntiSpoofPlugin plugin;
private final HttpClient httpClient;
private final BlockingQueue<String> queue = new LinkedBlockingQueue<>(MAX_QUEUE);
private final AtomicBoolean running = new AtomicBoolean(false);
private Thread workerThread;
public DiscordWebhookNotifier(AntiSpoofPlugin plugin) {
this.plugin = plugin;
this.httpClient = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(5))
.build();
}
public void start() {
if (!running.compareAndSet(false, true)) {
return;
}
workerThread = new Thread(this::drainLoop, "AntiSpoof-DiscordWebhook");
workerThread.setDaemon(true);
workerThread.start();
}
public void sendAlert(Player player, String violationType, String reason, long threatLevel) {
if (!plugin.getConfigManager().isDiscordEnabled()) {
return;
}
String url = plugin.getConfigManager().getDiscordWebhookUrl();
if (!isValidWebhookUrl(url)) {
return;
}
String brand = player != null ? safe(plugin.getPlayerBrand(player), "Unknown") : "Unknown";
String version = player != null ? safe(plugin.getPlayerVersion(player), "Unknown") : "Unknown";
OsInfo osInfo = player != null ? plugin.getOsInfo(player.getUniqueId()) : null;
String osName = osInfo != null ? osInfo.getOsName() : "Unknown";
String playerName = player != null ? player.getName() : "Unknown";
String uuidStr = player != null ? player.getUniqueId().toString() : "N/A";
int color = threatLevel >= 25 ? 0xE74C3C : (threatLevel >= 12 ? 0xE67E22 : 0xF1C40F);
String payload = buildEmbedJson(playerName, uuidStr, violationType, reason, brand, version, osName, threatLevel, color);
queue.offer(payload);
}
private void drainLoop() {
while (running.get()) {
try {
String payload = queue.take();
String url = plugin.getConfigManager().getDiscordWebhookUrl();
if (!plugin.getConfigManager().isDiscordEnabled() || !isValidWebhookUrl(url)) {
continue;
}
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(8))
.header("Content-Type", "application/json")
.header("User-Agent", "OpenAntiSpoof/1.5.0")
.POST(HttpRequest.BodyPublishers.ofString(payload, StandardCharsets.UTF_8))
.build();
HttpResponse<String> resp = httpClient.send(req, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
int code = resp.statusCode();
if (code == 429) {
Thread.sleep(3_000L);
} else if (code >= 400 && plugin.getConfigManager().isDebug()) {
plugin.getLogger().warning("[DiscordWebhook] HTTP " + code + ": " + resp.body());
}
Thread.sleep(MIN_INTERVAL_MS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
} catch (Throwable t) {
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().warning("[DiscordWebhook] Send failed: " + t.getMessage());
}
}
}
}
public void shutdown() {
running.set(false);
queue.clear();
if (workerThread != null) {
workerThread.interrupt();
}
}
private static boolean isValidWebhookUrl(String url) {
if (url == null || url.isBlank()) return false;
String lower = url.toLowerCase();
return lower.startsWith("https://discord.com/api/webhooks/")
|| lower.startsWith("https://discordapp.com/api/webhooks/")
|| lower.startsWith("https://canary.discord.com/api/webhooks/")
|| lower.startsWith("https://ptb.discord.com/api/webhooks/");
}
private static String buildEmbedJson(
String playerName,
String uuid,
String violationType,
String reason,
String brand,
String version,
String osName,
long threat,
int color
) {
return "{"
+ "\"embeds\":[{"
+ "\"title\":\"AntiSpoof Alert — " + esc(violationType) + "\","
+ "\"description\":\"" + esc(reason) + "\","
+ "\"color\":" + color + ","
+ "\"fields\":["
+ "{\"name\":\"Player\",\"value\":\"" + esc(playerName) + "\",\"inline\":true},"
+ "{\"name\":\"Brand\",\"value\":\"" + esc(brand) + "\",\"inline\":true},"
+ "{\"name\":\"Version\",\"value\":\"" + esc(version) + "\",\"inline\":true},"
+ "{\"name\":\"OS\",\"value\":\"" + esc(osName) + "\",\"inline\":true},"
+ "{\"name\":\"Threat Level\",\"value\":\"" + threat + "\",\"inline\":true},"
+ "{\"name\":\"UUID\",\"value\":\"`" + esc(uuid) + "`\",\"inline\":false}"
+ "],"
+ "\"footer\":{\"text\":\"OpenAntiSpoof-FullOpsec\"},"
+ "\"timestamp\":\"" + Instant.now().toString() + "\""
+ "}]}";
}
private static String safe(String v, String def) {
return (v == null || v.isBlank()) ? def : v;
}
private static String esc(String s) {
if (s == null) return "";
return s.replace("\\", "\\\\")
.replace("\"", "\\\"")
.replace("\n", "\\n")
.replace("\r", "");
}
}
@@ -181,6 +181,10 @@ public final class BrandChannelListener extends PacketListenerAbstract implement
plugin.getActiveReconScanner().scanOnTrigger(player, "JOIN"); plugin.getActiveReconScanner().scanOnTrigger(player, "JOIN");
} }
if (plugin.getProbeFreezeManager() != null && plugin.getProbeFreezeManager().isEnabled()) {
plugin.getProbeFreezeManager().freeze(player);
}
long delayTicks = Math.max(20L, plugin.getConfigManager().getDelayInSeconds() * 20L); long delayTicks = Math.max(20L, plugin.getConfigManager().getDelayInSeconds() * 20L);
SchedulerUtil.runEntityDelayed(plugin, player, () -> { SchedulerUtil.runEntityDelayed(plugin, player, () -> {
if (!player.isOnline() || plugin.isBypassed(uuid)) { if (!player.isOnline() || plugin.isBypassed(uuid)) {
@@ -302,6 +302,9 @@ public final class AssetProbeLabManager implements Listener {
} }
}, 30L); }, 30L);
} }
if (plugin.getProbeFreezeManager() != null) {
plugin.getProbeFreezeManager().tryUnfreezeIfClear(player);
}
} }
private void notifyTarget(CommandSender requester, Player target, String legacyMsg) { private void notifyTarget(CommandSender requester, Player target, String legacyMsg) {
@@ -3,9 +3,14 @@ package com.gigazelensky.antispoof.probe;
import com.gigazelensky.antispoof.config.AssetProbeRule; import com.gigazelensky.antispoof.config.AssetProbeRule;
import com.gigazelensky.antispoof.core.AntiSpoofPlugin; import com.gigazelensky.antispoof.core.AntiSpoofPlugin;
import com.gigazelensky.antispoof.core.ViolationType; import com.gigazelensky.antispoof.core.ViolationType;
import com.gigazelensky.antispoof.data.AssetCheckType;
import com.gigazelensky.antispoof.data.LogType; import com.gigazelensky.antispoof.data.LogType;
import com.gigazelensky.antispoof.data.PlayerProfile;
import com.gigazelensky.antispoof.util.SchedulerUtil; import com.gigazelensky.antispoof.util.SchedulerUtil;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@@ -18,18 +23,47 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerResourcePackStatusEvent; import org.bukkit.event.player.PlayerResourcePackStatusEvent;
/** /**
* Resource-pack asset detection probe (TEXTURES, FONT, CORRUPTION) (reconstructed from IIIIIIllllllIII). * Config-driven Resource-Pack Asset Probe engine (ported from IIIIIIllllllIII + IIllIlIIIIIIlII):
* supports TEXTURES (bitmap font provider with A/B missing-texture control verification),
* FONT (TTF font provider with A/B missing-font control verification), and CORRUPTION probes.
*/ */
public final class AssetProbeListener implements Listener { public final class AssetProbeListener implements Listener {
private static final int PACK_FORMAT_1_20_6 = 32;
private static final String CONTROL_MISSING_BITMAP = "antispoof_missing_ctrl:nope.png";
private static final String CONTROL_MISSING_TTF = "antispoof_missing_ctrl:nope.ttf";
private record QueuedPack(AssetProbeRule rule, AssetCheckType checkType, boolean control, String targetPath) {
}
private static final class PlayerAssetSession {
final UUID playerId;
final List<QueuedPack> queue;
int index;
UUID currentPackId;
String currentToken;
String bitmapControlStatus;
String fontControlStatus;
ScheduledTask timeoutTask;
PlayerAssetSession(UUID playerId, List<QueuedPack> queue) {
this.playerId = playerId;
this.queue = queue;
}
}
private final AntiSpoofPlugin plugin; private final AntiSpoofPlugin plugin;
private final ProbeHttpServer httpServer; private final ProbeHttpServer httpServer;
private final Map<UUID, AssetProbeRule> activeProbeByPlayer = new ConcurrentHashMap<>(); private final Map<UUID, PlayerAssetSession> activeSessions = new ConcurrentHashMap<>();
public AssetProbeListener(AntiSpoofPlugin plugin, ProbeHttpServer httpServer) { public AssetProbeListener(AntiSpoofPlugin plugin, ProbeHttpServer httpServer) {
this.plugin = plugin; this.plugin = plugin;
this.httpServer = httpServer; this.httpServer = httpServer;
} }
public boolean isRunning(UUID uuid) {
return uuid != null && activeSessions.containsKey(uuid);
}
public void startProbes(Player player) { public void startProbes(Player player) {
if (player == null || !player.isOnline() || httpServer == null) { if (player == null || !player.isOnline() || httpServer == null) {
return; return;
@@ -37,55 +71,249 @@ public final class AssetProbeListener implements Listener {
if (!plugin.getConfigManager().isAssetProbeEnabled() || plugin.isBedrock(player)) { if (!plugin.getConfigManager().isAssetProbeEnabled() || plugin.isBedrock(player)) {
return; return;
} }
List<AssetProbeRule> rules = plugin.getConfigManager().getAssetProbeRules();
for (AssetProbeRule rule : rules) { List<AssetProbeRule> enabled = new ArrayList<>();
if (!rule.isEnabled()) { boolean hasTextures = false;
boolean hasFont = false;
for (AssetProbeRule rule : plugin.getConfigManager().getAssetProbeRules()) {
if (!rule.isEnabled() || rule.getTargetPath() == null || rule.getTargetPath().isBlank()) {
continue; continue;
} }
activeProbeByPlayer.put(player.getUniqueId(), rule); enabled.add(rule);
String token = "asset-" + rule.getId() + "-" + player.getUniqueId() + ".zip"; if (rule.getCheckType() == AssetCheckType.TEXTURES) hasTextures = true;
byte[] zip = ProbeHttpServer.buildMinimalPack( if (rule.getCheckType() == AssetCheckType.FONT) hasFont = true;
"asset-" + rule.getId(),
rule.getTargetPath(),
"probe".getBytes(StandardCharsets.UTF_8)
);
byte[] hash = ProbeHttpServer.sha1(zip);
UUID packId = UUID.nameUUIDFromBytes(token.getBytes(StandardCharsets.UTF_8));
String url = httpServer.registerPack(player.getUniqueId(), token, zip, false);
SchedulerUtil.runEntity(plugin, player, () -> {
if (player.isOnline()) {
try {
player.addResourcePack(packId, url, hash, null, false);
} catch (Throwable ignored) {
}
}
});
break;
} }
if (enabled.isEmpty()) {
return;
}
List<QueuedPack> queue = new ArrayList<>();
if (hasTextures) {
queue.add(new QueuedPack(null, AssetCheckType.TEXTURES, true, CONTROL_MISSING_BITMAP));
}
if (hasFont) {
queue.add(new QueuedPack(null, AssetCheckType.FONT, true, CONTROL_MISSING_TTF));
}
for (AssetProbeRule rule : enabled) {
queue.add(new QueuedPack(rule, rule.getCheckType(), false, rule.getTargetPath()));
}
UUID uuid = player.getUniqueId();
cancelSession(uuid, player);
PlayerAssetSession session = new PlayerAssetSession(uuid, queue);
activeSessions.put(uuid, session);
dispatchNext(player, session);
}
private void dispatchNext(Player player, PlayerAssetSession session) {
if (!player.isOnline() || activeSessions.get(session.playerId) != session) {
return;
}
if (session.index >= session.queue.size()) {
finishSession(player, session);
return;
}
QueuedPack item = session.queue.get(session.index);
String nonce = TranslationProbeManager.generateNonce();
String label = item.control() ? ("ctrl-" + item.checkType().name().toLowerCase()) : item.rule().getId();
String token = "asset-" + label + "-" + nonce + ".zip";
UUID packId = UUID.randomUUID();
byte[] zip = buildAssetProbePack(item.checkType(), item.targetPath(), label);
byte[] hash = ProbeHttpServer.sha1(zip);
String url = httpServer.registerPack(session.playerId, token, zip, false);
session.currentPackId = packId;
session.currentToken = token;
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().info("[AssetProbe] Sending " + label + " (" + item.checkType() + ") -> "
+ item.targetPath() + " to " + player.getName());
}
SchedulerUtil.runEntity(plugin, player, () -> {
if (!player.isOnline()) return;
try {
player.addResourcePack(packId, url, hash, null, false);
} catch (Throwable t) {
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().warning("[AssetProbe] Failed to send pack " + label + ": " + t.getMessage());
}
advance(player, session, packId);
}
});
SchedulerUtil.cancelQuietly(session.timeoutTask);
int capturedIdx = session.index;
session.timeoutTask = SchedulerUtil.runEntityDelayed(plugin, player, () -> {
if (activeSessions.get(session.playerId) == session && session.index == capturedIdx) {
advance(player, session, packId);
}
}, 160L);
}
/**
* Exact IIllIlIIIIIIlII.G payload builder for TEXTURES, FONT, and CORRUPTION.
*/
public static byte[] buildAssetProbePack(AssetCheckType type, String targetPath, String marker) {
Map<String, byte[]> files = new LinkedHashMap<>();
String escaped = escapeJson(targetPath);
if (type == AssetCheckType.TEXTURES) {
String json = "{\"providers\":[{\"type\":\"bitmap\",\"file\":\"" + escaped
+ "\",\"ascent\":8,\"height\":8,\"chars\":[\"\\ue020\"]}]}";
files.put("assets/minecraft/font/default.json", json.getBytes(StandardCharsets.UTF_8));
} else if (type == AssetCheckType.FONT) {
String json = "{\"providers\":[{\"type\":\"ttf\",\"file\":\"" + escaped
+ "\",\"size\":11.0,\"oversample\":1.0,\"shift\":[0.0,0.0]}]}";
files.put("assets/minecraft/font/default.json", json.getBytes(StandardCharsets.UTF_8));
} else {
// CORRUPTION: write invalid data to mod asset path
files.put(targetPath, ("CORRUPTED_ASSET_PROBE_" + marker).getBytes(StandardCharsets.UTF_8));
}
return ProbeHttpServer.buildMultiFilePack(PACK_FORMAT_1_20_6, "AntiSpoof Asset " + marker, files);
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPackStatus(PlayerResourcePackStatusEvent event) { public void onPackStatus(PlayerResourcePackStatusEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
AssetProbeRule rule = activeProbeByPlayer.get(player.getUniqueId()); if (player == null) return;
if (rule == null) { PlayerAssetSession session = activeSessions.get(player.getUniqueId());
if (session == null || session.currentPackId == null || !session.currentPackId.equals(event.getID())) {
return; return;
} }
PlayerResourcePackStatusEvent.Status status = event.getStatus(); PlayerResourcePackStatusEvent.Status status = event.getStatus();
if (status == PlayerResourcePackStatusEvent.Status.ACCEPTED || status == PlayerResourcePackStatusEvent.Status.DOWNLOADED) { if (status == PlayerResourcePackStatusEvent.Status.ACCEPTED || status == PlayerResourcePackStatusEvent.Status.DOWNLOADED) {
return; return;
} }
activeProbeByPlayer.remove(player.getUniqueId());
SchedulerUtil.cancelQuietly(session.timeoutTask);
QueuedPack item = session.queue.get(session.index);
UUID completedPackId = session.currentPackId;
session.currentPackId = null;
if (item.control()) {
if (item.checkType() == AssetCheckType.TEXTURES) {
session.bitmapControlStatus = status.name();
} else if (item.checkType() == AssetCheckType.FONT) {
session.fontControlStatus = status.name();
}
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().info("[AssetProbe] Control(" + item.checkType() + ") for " + player.getName() + " = " + status);
}
} else {
evaluateRuleResult(player, session, item.rule(), status);
}
advance(player, session, completedPackId);
}
private void evaluateRuleResult(Player player, PlayerAssetSession session, AssetProbeRule rule, PlayerResourcePackStatusEvent.Status status) {
if (status == PlayerResourcePackStatusEvent.Status.DECLINED) { if (status == PlayerResourcePackStatusEvent.Status.DECLINED) {
plugin.flagPlayer(player, ViolationType.ASSET_DECLINED, "Declined asset probe pack (" + rule.getDisplayName() + ")"); plugin.flagPlayer(player, ViolationType.ASSET_DECLINED, "Declined asset probe pack (" + rule.getDisplayName() + ")");
} else if (status == PlayerResourcePackStatusEvent.Status.FAILED_DOWNLOAD || status == PlayerResourcePackStatusEvent.Status.FAILED_RELOAD) { return;
plugin.getPlayerLogManager().log(player, LogType.PROBE, "Asset probe triggered (" + rule.getCheckType() + "): " + rule.getDisplayName()); }
plugin.flagPlayer(player, ViolationType.ASSET_DETECTED, "Detected mod asset: " + rule.getDisplayName());
boolean detected = false;
String detail = "";
if (rule.getCheckType() == AssetCheckType.TEXTURES) {
// A/B verified: missing control returned FAILED_RELOAD, real mod texture returns SUCCESSFULLY_LOADED
if ("FAILED_RELOAD".equals(session.bitmapControlStatus) && status == PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED) {
detected = true;
detail = "Bitmap texture asset exists (" + rule.getTargetPath() + ", control=FAILED_RELOAD)";
}
} else if (rule.getCheckType() == AssetCheckType.FONT) {
if ("FAILED_RELOAD".equals(session.fontControlStatus) && status == PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED) {
detected = true;
detail = "Font asset exists (" + rule.getTargetPath() + ", control=FAILED_RELOAD)";
}
} else if (rule.getCheckType() == AssetCheckType.CORRUPTION) {
if (status == PlayerResourcePackStatusEvent.Status.FAILED_RELOAD) {
detected = true;
detail = "Corrupted mod asset triggered FAILED_RELOAD (" + rule.getTargetPath() + ")";
}
}
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().info("[AssetProbe] Rule " + rule.getId() + " (" + rule.getCheckType() + ") for "
+ player.getName() + " status=" + status + " detected=" + detected);
}
if (detected) {
PlayerProfile profile = plugin.getOrCreateProfile(player.getUniqueId());
profile.addDetectedMod(rule.getDisplayName());
profile.addAlertedMod(rule.getDisplayName());
plugin.getPlayerLogManager().log(player, LogType.PROBE, "Asset probe hit (" + rule.getCheckType() + "): " + rule.getDisplayName() + " - " + detail);
plugin.flagPlayer(player, ViolationType.ASSET_DETECTED, "Detected mod asset [" + rule.getDisplayName() + "]: " + detail);
if (rule.isPunish() && !rule.getPunishments().isEmpty()) {
plugin.executePunishment(
player,
ViolationType.ASSET_DETECTED,
detail,
plugin.getPlayerBrand(player),
rule.getDisplayName(),
rule.getPunishments(),
profile.getThreatLevel()
);
}
}
}
private void advance(Player player, PlayerAssetSession session, UUID packToRemove) {
session.index++;
SchedulerUtil.runEntity(plugin, player, () -> {
if (player.isOnline() && packToRemove != null) {
try {
player.removeResourcePack(packToRemove);
} catch (Throwable ignored) {
}
}
});
SchedulerUtil.runEntityDelayed(plugin, player, () -> {
if (player.isOnline() && activeSessions.get(session.playerId) == session) {
dispatchNext(player, session);
}
}, 25L);
}
private void finishSession(Player player, PlayerAssetSession session) {
activeSessions.remove(session.playerId, session);
SchedulerUtil.cancelQuietly(session.timeoutTask);
if (httpServer != null) {
httpServer.cleanupPlayer(session.playerId);
}
if (plugin.getProbeFreezeManager() != null) {
plugin.getProbeFreezeManager().tryUnfreezeIfClear(player);
}
}
private void cancelSession(UUID uuid, Player player) {
PlayerAssetSession prev = activeSessions.remove(uuid);
if (prev == null) return;
SchedulerUtil.cancelQuietly(prev.timeoutTask);
if (prev.currentPackId != null && player != null && player.isOnline()) {
try {
player.removeResourcePack(prev.currentPackId);
} catch (Throwable ignored) {
}
} }
} }
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent event) { public void onQuit(PlayerQuitEvent event) {
activeProbeByPlayer.remove(event.getPlayer().getUniqueId()); cancelSession(event.getPlayer().getUniqueId(), event.getPlayer());
}
public void shutdown() {
for (PlayerAssetSession s : activeSessions.values()) {
SchedulerUtil.cancelQuietly(s.timeoutTask);
}
activeSessions.clear();
}
private static String escapeJson(String s) {
if (s == null) return "";
return s.replace("\\", "\\\\").replace("\"", "\\\"");
} }
} }
@@ -159,6 +159,10 @@ public final class KeySpoofRpProbeManager extends PacketListenerAbstract impleme
return httpServer != null && plugin.getConfigManager().isKeySpoofProbeEnabled(); return httpServer != null && plugin.getConfigManager().isKeySpoofProbeEnabled();
} }
public boolean isRunning(UUID uuid) {
return uuid != null && sessions.containsKey(uuid);
}
public void startProbe(Player player, CommandSender requester) { public void startProbe(Player player, CommandSender requester) {
if (player == null || !player.isOnline() || plugin.isBedrock(player)) { if (player == null || !player.isOnline() || plugin.isBedrock(player)) {
return; return;
@@ -692,6 +696,8 @@ public final class KeySpoofRpProbeManager extends PacketListenerAbstract impleme
plugin.getAssetProbeLabManager().startLab(player, null); plugin.getAssetProbeLabManager().startLab(player, null);
} }
}, 15L); }, 15L);
} else if (plugin.getProbeFreezeManager() != null) {
plugin.getProbeFreezeManager().tryUnfreezeIfClear(player);
} }
} }
@@ -0,0 +1,186 @@
package com.gigazelensky.antispoof.probe;
import com.gigazelensky.antispoof.core.AntiSpoofPlugin;
import com.gigazelensky.antispoof.util.SchedulerUtil;
import com.gigazelensky.antispoof.util.TextUtil;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
/**
* Freezes players (movement, actions, and non-whitelisted commands) while AntiSpoof probes
* are running, with an automatic safety timeout (reconstructed from probe-freeze subsystem).
*/
public final class ProbeFreezeManager implements Listener {
private final AntiSpoofPlugin plugin;
private final Map<UUID, ScheduledTask> frozenPlayers = new ConcurrentHashMap<>();
private volatile List<Pattern> allowedCommandPatterns = List.of();
public ProbeFreezeManager(AntiSpoofPlugin plugin) {
this.plugin = plugin;
reloadPatterns();
}
public void reloadPatterns() {
List<Pattern> compiled = new ArrayList<>();
for (String raw : plugin.getConfigManager().getProbeFreezeAllowedCommands()) {
if (raw == null || raw.isBlank()) continue;
try {
compiled.add(Pattern.compile(raw, Pattern.CASE_INSENSITIVE));
} catch (Exception ignored) {
}
}
this.allowedCommandPatterns = List.copyOf(compiled);
}
public boolean isEnabled() {
return plugin.getConfigManager().isProbeFreezeEnabled();
}
public boolean isFrozen(UUID uuid) {
return uuid != null && frozenPlayers.containsKey(uuid);
}
public void freeze(Player player) {
if (player == null || !player.isOnline() || !isEnabled()) {
return;
}
UUID uuid = player.getUniqueId();
if (plugin.isBypassed(uuid) || player.hasPermission("antispoof.bypass")) {
return;
}
ScheduledTask prev = frozenPlayers.remove(uuid);
SchedulerUtil.cancelQuietly(prev);
long timeoutTicks = Math.max(40L, plugin.getConfigManager().getProbeFreezeTimeoutSeconds() * 20L);
ScheduledTask safetyTask = SchedulerUtil.runEntityDelayed(plugin, player, () -> {
if (frozenPlayers.remove(uuid) != null && plugin.getConfigManager().isDebug()) {
plugin.getLogger().info("[ProbeFreeze] Auto-unfroze " + player.getName() + " after safety timeout.");
}
}, timeoutTicks);
frozenPlayers.put(uuid, safetyTask);
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().info("[ProbeFreeze] Froze " + player.getName() + " during verification probes.");
}
}
public void unfreeze(UUID uuid) {
if (uuid == null) return;
ScheduledTask task = frozenPlayers.remove(uuid);
SchedulerUtil.cancelQuietly(task);
}
public void tryUnfreezeIfClear(Player player) {
if (player == null) return;
UUID uuid = player.getUniqueId();
if (!isFrozen(uuid)) return;
boolean assetBusy = plugin.getAssetProbeListener() != null && plugin.getAssetProbeListener().isRunning(uuid);
boolean keySpoofBusy = plugin.getKeySpoofRpProbeManager() != null && plugin.getKeySpoofRpProbeManager().isRunning(uuid);
if (!assetBusy && !keySpoofBusy) {
unfreeze(uuid);
if (plugin.getConfigManager().isDebug()) {
plugin.getLogger().info("[ProbeFreeze] Unfroze " + player.getName() + " (probes complete).");
}
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onMove(PlayerMoveEvent event) {
if (!isFrozen(event.getPlayer().getUniqueId())) return;
Location from = event.getFrom();
Location to = event.getTo();
if (to == null) return;
if (from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ()) {
Location locked = from.clone();
locked.setYaw(to.getYaw());
locked.setPitch(to.getPitch());
event.setTo(locked);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onInteract(PlayerInteractEvent event) {
if (isFrozen(event.getPlayer().getUniqueId())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
if (isFrozen(event.getPlayer().getUniqueId())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
if (isFrozen(event.getPlayer().getUniqueId())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onDrop(PlayerDropItemEvent event) {
if (isFrozen(event.getPlayer().getUniqueId())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onDamage(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player p && isFrozen(p.getUniqueId())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOW)
public void onCommand(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
if (!isFrozen(player.getUniqueId())) return;
String msg = event.getMessage() == null ? "" : event.getMessage().trim();
// Always permit AntiSpoof command-book verification tokens
if (msg.regionMatches(true, 0, "/asverify_", 0, 10)) {
return;
}
for (Pattern pat : allowedCommandPatterns) {
if (pat.matcher(msg).matches()) {
return;
}
}
event.setCancelled(true);
player.sendMessage(TextUtil.toComponent(plugin.getConfigManager().expandPrefixes(
"%prefix% &ePlease wait while client verification completes..."
)));
}
@EventHandler
public void onQuit(PlayerQuitEvent event) {
unfreeze(event.getPlayer().getUniqueId());
}
public void shutdown() {
for (ScheduledTask t : frozenPlayers.values()) {
SchedulerUtil.cancelQuietly(t);
}
frozenPlayers.clear();
}
}
+15 -1
View File
@@ -221,9 +221,23 @@ identity-linker:
banned-account-actions: banned-account-actions:
use-litebans-api: false use-litebans-api: false
probe-freeze:
enabled: false
timeout-seconds: 15
allowed-commands:
- "^/(login|register|l|reg)(\\s.*)?$"
asset-probe: asset-probe:
enabled: false enabled: false
rules: {} rules:
meteor-logo:
enabled: true
type: TEXTURES
path: "meteor-client:meteor.png"
name: "Meteor Client"
punish: false
discord-alert: true
punishments: []
key-spoof-probe: key-spoof-probe:
enabled: true enabled: true