From dba308efd206d8788e0cda7c7442381911946229 Mon Sep 17 00:00:00 2001 From: obvWolf Date: Thu, 18 Jan 2024 01:17:54 -0600 Subject: [PATCH] Trying to fix dictionary saving --- .../sentinel/data/FilterSeverity.java | 23 ++++++ .../server/functions/AdvancedBlockers.java | 14 ++++ src/main/resources/lang/en_us.json | 4 +- src/main/resources/main-config.json | 81 +++++++++++++++++++ 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 src/main/java/io/github/thetrouper/sentinel/data/FilterSeverity.java create mode 100644 src/main/resources/main-config.json diff --git a/src/main/java/io/github/thetrouper/sentinel/data/FilterSeverity.java b/src/main/java/io/github/thetrouper/sentinel/data/FilterSeverity.java new file mode 100644 index 0000000..2eb93b9 --- /dev/null +++ b/src/main/java/io/github/thetrouper/sentinel/data/FilterSeverity.java @@ -0,0 +1,23 @@ +package io.github.thetrouper.sentinel.data; + +import io.github.thetrouper.sentinel.Sentinel; + +public enum FilterSeverity { + LOW(Sentinel.mainConfig.chat.antiSwear.lowScore), + MEDIUM_LOW(Sentinel.mainConfig.chat.antiSwear.mediumLowScore), + MEDIUM(Sentinel.mainConfig.chat.antiSwear.mediumScore), + MEDIUM_HIGH(Sentinel.mainConfig.chat.antiSwear.mediumHighScore), + HIGH(Sentinel.mainConfig.chat.antiSwear.highScore), + SLUR(Sentinel.mainConfig.chat.antiSwear.highScore), + SAFE(0); + + private final int score; + + FilterSeverity(int score) { + this.score = score; + } + + public int getScore() { + return score; + } +} diff --git a/src/main/java/io/github/thetrouper/sentinel/server/functions/AdvancedBlockers.java b/src/main/java/io/github/thetrouper/sentinel/server/functions/AdvancedBlockers.java index b574421..6991ef2 100644 --- a/src/main/java/io/github/thetrouper/sentinel/server/functions/AdvancedBlockers.java +++ b/src/main/java/io/github/thetrouper/sentinel/server/functions/AdvancedBlockers.java @@ -1,6 +1,20 @@ package io.github.thetrouper.sentinel.server.functions; +import io.github.thetrouper.sentinel.Sentinel; +import io.github.thetrouper.sentinel.server.util.Text; +import org.bukkit.event.player.AsyncPlayerChatEvent; + public class AdvancedBlockers { + public static void handleAntiURL(AsyncPlayerChatEvent e) { + String message = Text.removeFirstColor(e.getMessage()); + String nonAllowed = message.replaceAll("[A-Za-z0-9\\[,./?><|\\]§()*&^%$#@!~`{}:;'\"-_]", "").trim(); + if (message.matches("https?://(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)")) { + } + if (nonAllowed.length() != 0) { + e.getPlayer().sendMessage(Text.prefix(Sentinel.dict.get("unicode-warn"))); + e.setCancelled(true); + } + } } diff --git a/src/main/resources/lang/en_us.json b/src/main/resources/lang/en_us.json index eaedcc6..c20a764 100644 --- a/src/main/resources/lang/en_us.json +++ b/src/main/resources/lang/en_us.json @@ -1,6 +1,6 @@ { - "dictionary" : { - "if-you-see-this-lang-is-broken" : "Sentinel language is working!", + "dictionary" : { // Comment! + "if-you-see-this-lang-is-broken" : "Sentinel language is working!", // Comment! "no-permission" : "§cInsufficient Permissions!", "cooldown" : "This action is on cooldown!", "false-positive-report-success" : "Successfully reported a false positive!", diff --git a/src/main/resources/main-config.json b/src/main/resources/main-config.json new file mode 100644 index 0000000..3d1886b --- /dev/null +++ b/src/main/resources/main-config.json @@ -0,0 +1,81 @@ +{ // Comment! + "plugin": { + "license": "beta", // Here is a comment! + "prefix": "§d§lSentinel §8» §7", // Here is another one! + "webhook": "https://discord.com/api/webhooks/id/token", + "lang": "en-us.json", + "trustedPlayers": [ + "049460f7-21cb-42f5-8059-d42752bf406f" + ], + "blockSpecific": true, + "preventNBT": true, + "preventCmdBlockPlace": true, + "preventCmdBlockUse": true, + "preventCmdBlockChange": true, + "preventCmdCartPlace": true, + "preventCmdCartUse": true, + "cmdBlockOpCheck": true, + "dangerous": [ + "op", + "deop", + "stop", + "restart", + "execute", + "sudo", + "esudo", + "fill", + "setblock", + "data", + "whitelist" + ], + "logDangerous": true, + "logCmdBlocks": true, + "logNBT": true, + "logSpecific": false, + "logged": [ + "give", + "item" + ], + "deop": true, + "nbtPunish": false, + "cmdBlockPunish": false, + "commandPunish": false, + "specificPunish": false, + "punishCommands": [ + "smite %player%", + "ban %player% ]\u003d- Sentinel -\u003d[ You have been banned for attempting a dangerous action. If you believe this to be a mistake, please contact the server owner." + ], + "reopCommand": false + }, + "chat": { + "antiSwear": { + "antiSwearEnabled": true, + "lowScore": 0, + "mediumLowScore": 1, + "mediumScore": 3, + "mediumHighScore": 5, + "highScore": 7, + "scoreDecay": 3, + "punishScore": 20, + "strictInstaPunish": true, + "swearPunishCommand": "mute %player% 15m Do not attempt to bypass the Profanity Filter", + "strictPunishCommand": "mute %player% 1h Discriminatory speech is not tolerated on this server!", + "logSwears": true + }, + "antiSpam": { + "antiSpamEnabled": true, + "defaultGain": 1, + "lowGain": 2, + "mediumGain": 4, + "highGain": 6, + "heatDecay": 1, + "blockHeat": 10, + "punishHeat": 25, + "clearChat": true, + "chatClearCommand": "cc", + "spamPunishCommand": "mute %player% 1m Please refrain from spamming!", + "logSpam": true + }, + "antiUnicode": true + } +}