diff --git a/build.gradle b/build.gradle index f966719..8c4c68e 100644 --- a/build.gradle +++ b/build.gradle @@ -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 diff --git a/libs/JDWebHooks-1.0.1.jar b/libs/JDWebHooks-1.0.1.jar new file mode 100644 index 0000000..b3a94cb Binary files /dev/null and b/libs/JDWebHooks-1.0.1.jar differ diff --git a/libs/PDK-1.3.3.jar b/libs/PDK-1.3.4.jar similarity index 100% rename from libs/PDK-1.3.3.jar rename to libs/PDK-1.3.4.jar diff --git a/src/main/java/io/github/thetrouper/sentinel/Sentinel.java b/src/main/java/io/github/thetrouper/sentinel/Sentinel.java index 6bd5420..b045dec 100644 --- a/src/main/java/io/github/thetrouper/sentinel/Sentinel.java +++ b/src/main/java/io/github/thetrouper/sentinel/Sentinel.java @@ -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 diff --git a/src/main/java/io/github/thetrouper/sentinel/cmds/SentinelCommand.java b/src/main/java/io/github/thetrouper/sentinel/cmds/SentinelCommand.java index 79f94cd..a40187e 100644 --- a/src/main/java/io/github/thetrouper/sentinel/cmds/SentinelCommand.java +++ b/src/main/java/io/github/thetrouper/sentinel/cmds/SentinelCommand.java @@ -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"))); } diff --git a/src/main/java/io/github/thetrouper/sentinel/server/Action.java b/src/main/java/io/github/thetrouper/sentinel/server/Action.java index 4ee6931..961e3df 100644 --- a/src/main/java/io/github/thetrouper/sentinel/server/Action.java +++ b/src/main/java/io/github/thetrouper/sentinel/server/Action.java @@ -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"). diff --git a/src/main/java/io/github/thetrouper/sentinel/server/functions/SystemCheck.java b/src/main/java/io/github/thetrouper/sentinel/server/functions/SystemCheck.java new file mode 100644 index 0000000..c87f375 --- /dev/null +++ b/src/main/java/io/github/thetrouper/sentinel/server/functions/SystemCheck.java @@ -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"); + + } +} diff --git a/src/main/java/io/github/thetrouper/sentinel/server/functions/Telemetry.java b/src/main/java/io/github/thetrouper/sentinel/server/functions/Telemetry.java index 175b108..c04793b 100644 --- a/src/main/java/io/github/thetrouper/sentinel/server/functions/Telemetry.java +++ b/src/main/java/io/github/thetrouper/sentinel/server/functions/Telemetry.java @@ -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" + - Emojis.rightSort + " License: ||" + Sentinel.license + "||\n" + - Emojis.rightSort + " IP: ||" + Sentinel.IP + "||") - .setColor(Color.GREEN.getRGB()) - .build()) - .build(); try { - telemetryHook.send(embed); + 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 + "||") + .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" + - Emojis.rightSort + " License: ||" + Sentinel.license + "||\n" + - Emojis.rightSort + " IP: ||" + Sentinel.IP + "||") - .setColor(Color.RED.getRGB()) - .build()) - .build(); + public static void sendShutdownLog() { try { - telemetryHook.send(embed); - return true; + 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 + "||") + .color(0xFF0000) + .build() + ).send(webhook); } catch (Exception ex) { Sentinel.log.info("Failed to send dynamic shutdown!"); - return false; } }