System check + webhook refactor
This commit is contained in:
@@ -30,7 +30,7 @@ dependencies {
|
||||
compileOnly 'org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT'
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation 'club.minnced:discord-webhooks:0.8.4'
|
||||
implementation files("libs/PDK-1.3.3.jar")
|
||||
implementation files("libs/PDK-1.3.4.jar")
|
||||
}
|
||||
|
||||
def targetJavaVersion = 16
|
||||
|
||||
BIN
libs/JDWebHooks-1.0.1.jar
Normal file
BIN
libs/JDWebHooks-1.0.1.jar
Normal file
Binary file not shown.
@@ -45,7 +45,6 @@ public final class Sentinel extends JavaPlugin {
|
||||
public static String serverID;
|
||||
public static String license;
|
||||
public static String IP;
|
||||
public static WebhookClient webclient;
|
||||
|
||||
/**
|
||||
* Plugin startup logic
|
||||
|
||||
@@ -33,6 +33,9 @@ public class SentinelCommand implements CustomCommand {
|
||||
p.sendMessage(Text.prefix("Reloading Sentinel!"));
|
||||
Sentinel.log.info("[Sentinel] Re-Initializing Sentinel!");
|
||||
instance.loadConfig();
|
||||
}
|
||||
case "full-system-check" -> {
|
||||
|
||||
}
|
||||
case "debug" -> {
|
||||
switch (args.get(1).toString()) {
|
||||
@@ -86,7 +89,7 @@ public class SentinelCommand implements CustomCommand {
|
||||
|
||||
@Override
|
||||
public void dispatchCompletions(CompletionBuilder b) {
|
||||
b.then(b.arg("reload","getheat"));
|
||||
b.then(b.arg("reload","getheat","full-system-check"));
|
||||
b.then(b.arg("debug").then(
|
||||
b.arg("antiswear","antispam","lang","toggle")));
|
||||
}
|
||||
|
||||
@@ -5,10 +5,11 @@ import club.minnced.discord.webhook.send.WebhookEmbed;
|
||||
import club.minnced.discord.webhook.send.WebhookEmbedBuilder;
|
||||
import club.minnced.discord.webhook.send.WebhookMessage;
|
||||
import club.minnced.discord.webhook.send.WebhookMessageBuilder;
|
||||
import io.github.itzispyder.pdk.PDK;
|
||||
import io.github.itzispyder.pdk.utils.discord.DiscordWebhook;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.data.Emojis;
|
||||
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
||||
import io.github.thetrouper.sentinel.server.util.FileUtils;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import io.github.thetrouper.sentinel.server.util.Text;
|
||||
@@ -173,6 +174,7 @@ public class Action {
|
||||
actions += (revertGM) ? Emojis.rightSort + " **GM Reverted:** " + Emojis.success + "\n" : "";
|
||||
actions += Emojis.rightSort + " **Logged:** " + Emojis.success;
|
||||
|
||||
Webhook
|
||||
WebhookMessage message = new WebhookMessageBuilder()
|
||||
.setUsername("Sentinel Anti-Nuke | Logs")
|
||||
.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png").
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package io.github.thetrouper.sentinel.server.functions;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.SchedulerUtils;
|
||||
import io.github.itzispyder.pdk.utils.discord.DiscordWebhook;
|
||||
import io.github.thetrouper.sentinel.cmds.SocialSpyCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class SystemCheck {
|
||||
public static void fullCheck(Player p) {
|
||||
chatCheck(p);
|
||||
|
||||
}
|
||||
public static void chatCheck(Player p) {
|
||||
SocialSpyCommand.spyMap.put(p.getUniqueId(),true);
|
||||
AsyncPlayerChatEvent swear = new AsyncPlayerChatEvent(true,p,"Sentinel AntiSwear check > Fvck", Set.of(p));
|
||||
AsyncPlayerChatEvent spam = new AsyncPlayerChatEvent(true,p,"Sentinel AntiSpam Check", Set.of(p));
|
||||
ProfanityFilter.handleProfanityFilter(swear);
|
||||
SchedulerUtils.loop(10,5, (loop)->{
|
||||
AntiSpam.lastMessageMap.put(p,"Sentinel AntiSpam Check");
|
||||
AntiSpam.handleAntiSpam(spam);
|
||||
});
|
||||
|
||||
|
||||
Message.messagePlayer(p,p,"Sentinel Automatic System Check > Private Message");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import club.minnced.discord.webhook.send.WebhookEmbed;
|
||||
import club.minnced.discord.webhook.send.WebhookEmbedBuilder;
|
||||
import club.minnced.discord.webhook.send.WebhookMessage;
|
||||
import club.minnced.discord.webhook.send.WebhookMessageBuilder;
|
||||
import io.github.itzispyder.pdk.utils.discord.DiscordEmbed;
|
||||
import io.github.itzispyder.pdk.utils.discord.DiscordWebhook;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.Emojis;
|
||||
import io.github.thetrouper.sentinel.server.util.CipherUtils;
|
||||
@@ -20,34 +22,25 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Telemetry {
|
||||
public static WebhookClient telemetryHook;
|
||||
public static String webhook;
|
||||
public static void initTelemetryHook() {
|
||||
WebhookClientBuilder builder = new WebhookClientBuilder(fetchTelemetryHook());
|
||||
builder.setThreadFactory((job) -> {
|
||||
Thread thread = new Thread(job);
|
||||
thread.setName("WebhookThread");
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
});
|
||||
builder.setWait(true);
|
||||
telemetryHook = builder.build();
|
||||
webhook = fetchTelemetryHook();
|
||||
}
|
||||
|
||||
public static boolean sendStartupLog() {
|
||||
WebhookMessage embed = new WebhookMessageBuilder()
|
||||
.setUsername("Sentinel Anti-Nuke | Telemetry")
|
||||
.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png").
|
||||
addEmbeds(new WebhookEmbedBuilder()
|
||||
.setAuthor(new WebhookEmbed.EmbedAuthor("Server Startup Log",null,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/"))
|
||||
.setTitle(new WebhookEmbed.EmbedTitle("A server has started up successfully",null))
|
||||
.setDescription("Server " + Sentinel.serverID + "\n" +
|
||||
try {
|
||||
DiscordWebhook.create()
|
||||
.username("Sentinel Anti-Nuke | Telemetry")
|
||||
.avatar("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png")
|
||||
.addEmbed(DiscordEmbed.create()
|
||||
.author(new DiscordEmbed.Author("Server Startup Log","https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null))
|
||||
.title("A server has started up successfully")
|
||||
.desc("Server " + Sentinel.serverID + "\n" +
|
||||
Emojis.rightSort + " License: ||" + Sentinel.license + "||\n" +
|
||||
Emojis.rightSort + " IP: ||" + Sentinel.IP + "||")
|
||||
.setColor(Color.GREEN.getRGB())
|
||||
.build())
|
||||
.build();
|
||||
try {
|
||||
telemetryHook.send(embed);
|
||||
.color(0x44FF44)
|
||||
.build()
|
||||
).send(webhook);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
Sentinel.log.info("Failed to initialize dynamic auth!");
|
||||
@@ -55,25 +48,22 @@ public class Telemetry {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean sendShutdownLog() {
|
||||
WebhookMessage embed = new WebhookMessageBuilder()
|
||||
.setUsername("Sentinel Anti-Nuke | Telemetry")
|
||||
.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png").
|
||||
addEmbeds(new WebhookEmbedBuilder()
|
||||
.setAuthor(new WebhookEmbed.EmbedAuthor("Server Shutdown Log",null,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/"))
|
||||
.setTitle(new WebhookEmbed.EmbedTitle("A server has shut down successfully",null))
|
||||
.setDescription("Server " + Sentinel.serverID + "\n" +
|
||||
public static void sendShutdownLog() {
|
||||
try {
|
||||
DiscordWebhook.create()
|
||||
.username("Sentinel Anti-Nuke | Telemetry")
|
||||
.avatar("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png")
|
||||
.addEmbed(DiscordEmbed.create()
|
||||
.author(new DiscordEmbed.Author("Server Shutdown Log","https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null))
|
||||
.title("A server has shut down")
|
||||
.desc("Server " + Sentinel.serverID + "\n" +
|
||||
Emojis.rightSort + " License: ||" + Sentinel.license + "||\n" +
|
||||
Emojis.rightSort + " IP: ||" + Sentinel.IP + "||")
|
||||
.setColor(Color.RED.getRGB())
|
||||
.build())
|
||||
.build();
|
||||
try {
|
||||
telemetryHook.send(embed);
|
||||
return true;
|
||||
.color(0xFF0000)
|
||||
.build()
|
||||
).send(webhook);
|
||||
} catch (Exception ex) {
|
||||
Sentinel.log.info("Failed to send dynamic shutdown!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user