Trying to fix dictionary saving

This commit is contained in:
obvWolf
2024-01-18 01:17:54 -06:00
parent c92cf71b07
commit dba308efd2
4 changed files with 120 additions and 2 deletions

View File

@@ -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;
}
}

View File

@@ -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);
}
}
}