Compare commits
4 Commits
4a2625ea1d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2deea9f69e | |||
| a95f5c02b3 | |||
| 55d342c7cd | |||
| 91b1fa24ba |
@@ -42,10 +42,6 @@ public class GriefDetectPlugin extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// Cleanup resources
|
// Cleanup resources
|
||||||
if (detectionEngine != null) {
|
|
||||||
detectionEngine.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
getLogger().info("GriefDetect disabled");
|
getLogger().info("GriefDetect disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,31 +79,21 @@ public class DetectionEngine implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown the detection engine.
|
* Analyze clusters and generate detection events.
|
||||||
*/
|
*/
|
||||||
public void shutdown() {
|
private void analyzeClusters() {
|
||||||
asyncExecutor.shutdown();
|
long now = System.currentTimeMillis();
|
||||||
try {
|
long maxAge = 300000L; // 5 minutes default
|
||||||
if (!asyncExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
|
|
||||||
asyncExecutor.shutdownNow();
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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()));
|
embed.put("color", getConfidenceColor(event.getConfidence()));
|
||||||
|
|
||||||
// Fields for additional information
|
// Fields for additional information
|
||||||
StringBuilder fieldsText = new StringBuilder();
|
|
||||||
|
|
||||||
// Nearest players field
|
|
||||||
if (!event.getNearestPlayers().isEmpty()) {
|
if (!event.getNearestPlayers().isEmpty()) {
|
||||||
fieldsText.append("**Players:**\n");
|
// Players field
|
||||||
|
StringBuilder playersText = new StringBuilder();
|
||||||
for (DetectionEvent.NearestPlayerInfo player : event.getNearestPlayers()) {
|
for (DetectionEvent.NearestPlayerInfo player : event.getNearestPlayers()) {
|
||||||
String gamemode = player.isSurvival() ? "Survival" : "Creative";
|
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));
|
player.getPlayerName(), player.getDistance(), gamemode));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Teleport command field
|
// Teleport command field
|
||||||
String tpCommand = String.format("/tp %d %d %d",
|
String tpCommand = String.format("/tp %d %d %d",
|
||||||
event.getCenter().getBlockX(),
|
event.getCenter().getBlockX(),
|
||||||
event.getCenter().getBlockY(),
|
event.getCenter().getBlockY(),
|
||||||
event.getCenter().getBlockZ());
|
event.getCenter().getBlockZ());
|
||||||
fieldsText.append("\n**Teleport:** `").append(tpCommand).append("`");
|
|
||||||
|
|
||||||
if (fieldsText.length() > 0) {
|
// Create fields array
|
||||||
embed.put("fields", fieldsText.toString());
|
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
|
// 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.
Binary file not shown.
Reference in New Issue
Block a user