fix webhook format and cluster repeat detection issues
This commit is contained in:
@@ -79,32 +79,21 @@ public class DetectionEngine implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown the detection engine.
|
||||
* Analyze clusters and generate detection events.
|
||||
*/
|
||||
public void shutdown() {
|
||||
asyncExecutor.shutdown();
|
||||
try {
|
||||
if (!asyncExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
|
||||
asyncExecutor.shutdownNow();
|
||||
private void analyzeClusters() {
|
||||
long now = System.currentTimeMillis();
|
||||
long maxAge = 300000L; // 5 minutes default
|
||||
|
||||
for (Map.Entry<String, Cluster> entry : activeClusters.entrySet()) {
|
||||
String worldName = entry.getKey();
|
||||
Cluster cluster = entry.getValue();
|
||||
|
||||
// Only analyze if cluster hasn't been evaluated recently
|
||||
if (cluster.shouldEvaluate()) {
|
||||
// Evaluate cluster directly
|
||||
evaluateCluster(cluster);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
asyncExecutor.shutdownNow();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
plugin.getLogger().info("Detection engine stopped");
|
||||
}
|
||||
|
||||
/**
|
||||
* Event capture methods - minimal processing on main thread.
|
||||
*/
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
// Capture lava-water interactions
|
||||
if (event.getBlock().getType().name().contains("LAVA") &&
|
||||
(event.getToBlock().getType().name().contains("WATER") ||
|
||||
event.getToBlock().getType().name().contains("ICE"))) {
|
||||
processBlockEvent(event.getBlock(), event.getToBlock().getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,27 +141,33 @@ public class WebhookManager {
|
||||
embed.put("color", getConfidenceColor(event.getConfidence()));
|
||||
|
||||
// Fields for additional information
|
||||
StringBuilder fieldsText = new StringBuilder();
|
||||
|
||||
// Nearest players field
|
||||
if (!event.getNearestPlayers().isEmpty()) {
|
||||
fieldsText.append("**Players:**\n");
|
||||
// Players field
|
||||
StringBuilder playersText = new StringBuilder();
|
||||
for (DetectionEvent.NearestPlayerInfo player : event.getNearestPlayers()) {
|
||||
String gamemode = player.isSurvival() ? "Survival" : "Creative";
|
||||
fieldsText.append(String.format("- %s (%.1fm, %s)\n",
|
||||
playersText.append(String.format("- %s (%.1fm, %s)\n",
|
||||
player.getPlayerName(), player.getDistance(), gamemode));
|
||||
}
|
||||
}
|
||||
|
||||
// Teleport command field
|
||||
String tpCommand = String.format("/tp %d %d %d",
|
||||
event.getCenter().getBlockX(),
|
||||
event.getCenter().getBlockY(),
|
||||
event.getCenter().getBlockZ());
|
||||
fieldsText.append("\n**Teleport:** `").append(tpCommand).append("`");
|
||||
|
||||
if (fieldsText.length() > 0) {
|
||||
embed.put("fields", fieldsText.toString());
|
||||
|
||||
// Teleport command field
|
||||
String tpCommand = String.format("/tp %d %d %d",
|
||||
event.getCenter().getBlockX(),
|
||||
event.getCenter().getBlockY(),
|
||||
event.getCenter().getBlockZ());
|
||||
|
||||
// Create fields array
|
||||
ObjectNode playersField = objectMapper.createObjectNode();
|
||||
playersField.put("name", "Players");
|
||||
playersField.put("value", playersText.toString());
|
||||
playersField.put("inline", false);
|
||||
|
||||
ObjectNode teleportField = objectMapper.createObjectNode();
|
||||
teleportField.put("name", "Teleport Command");
|
||||
teleportField.put("value", "`" + tpCommand + "`");
|
||||
teleportField.put("inline", false);
|
||||
|
||||
embed.set("fields", objectMapper.createArrayNode().add(playersField).add(teleportField));
|
||||
}
|
||||
|
||||
// Timestamp
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user