Fixed the anti-unicode
This commit is contained in:
@@ -49,6 +49,7 @@ public abstract class Config {
|
|||||||
public static List<String> punishCommands;
|
public static List<String> punishCommands;
|
||||||
public static boolean reopCommand;
|
public static boolean reopCommand;
|
||||||
|
|
||||||
|
public static boolean blockUnicode;
|
||||||
public static boolean antiSpamEnabled;
|
public static boolean antiSpamEnabled;
|
||||||
public static int defaultGain;
|
public static int defaultGain;
|
||||||
public static int lowGain;
|
public static int lowGain;
|
||||||
@@ -101,6 +102,8 @@ public abstract class Config {
|
|||||||
specificPunish = config.getBoolean("config.plugin.punish-specific");
|
specificPunish = config.getBoolean("config.plugin.punish-specific");
|
||||||
punishCommands = config.getStringList("config.plugin.punish-commands");
|
punishCommands = config.getStringList("config.plugin.punish-commands");
|
||||||
reopCommand = config.getBoolean("config.plugin.reop-command");
|
reopCommand = config.getBoolean("config.plugin.reop-command");
|
||||||
|
// Chat
|
||||||
|
blockUnicode = config.getBoolean("config.chat.anti-unicode");
|
||||||
// antiSpam
|
// antiSpam
|
||||||
antiSpamEnabled = config.getBoolean("config.chat.anti-spam.enabled");
|
antiSpamEnabled = config.getBoolean("config.chat.anti-spam.enabled");
|
||||||
defaultGain = config.getInt("config.chat.anti-spam.default-gain");
|
defaultGain = config.getInt("config.chat.anti-spam.default-gain");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.github.thetrouper.sentinel.events;
|
|||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
import io.github.thetrouper.sentinel.data.Config;
|
||||||
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
||||||
|
import io.github.thetrouper.sentinel.server.functions.AntiUnicode;
|
||||||
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -15,5 +16,6 @@ public class ChatEvent implements Listener {
|
|||||||
if (e.isCancelled()) return;
|
if (e.isCancelled()) return;
|
||||||
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antiswear.bypass")) if (Config.antiSwearEnabled) ProfanityFilter.handleProfanityFilter(e);
|
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antiswear.bypass")) if (Config.antiSwearEnabled) ProfanityFilter.handleProfanityFilter(e);
|
||||||
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antispam.bypass")) if (Config.antiSpamEnabled) AntiSpam.handleAntiSpam(e);
|
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antispam.bypass")) if (Config.antiSpamEnabled) AntiSpam.handleAntiSpam(e);
|
||||||
|
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antiunicode.bypass")) if (Config.blockUnicode) AntiUnicode.handleAntiUnicode(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,20 @@ public class TakeAction {
|
|||||||
NotifyConsole.command(e.getPlayer(),message,denied,deoped,punished,logged);
|
NotifyConsole.command(e.getPlayer(),message,denied,deoped,punished,logged);
|
||||||
NotifyTrusted.command(e.getPlayer(),message,denied,deoped,punished,logged);
|
NotifyTrusted.command(e.getPlayer(),message,denied,deoped,punished,logged);
|
||||||
}
|
}
|
||||||
|
public static void logged(PlayerCommandPreprocessEvent e) {
|
||||||
|
boolean deoped = false;
|
||||||
|
boolean punished = false;
|
||||||
|
boolean denied = false;
|
||||||
|
boolean logged = false;
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
String message = e.getMessage();
|
||||||
|
String command = e.getMessage().substring(1).split(" ")[0];
|
||||||
|
if (Sentinel.isLoggedCommand(command)) {
|
||||||
|
NotifyDiscord.command(e.getPlayer(),message,denied,deoped,punished,true);
|
||||||
|
NotifyConsole.command(e.getPlayer(),message,denied,deoped,punished,logged);
|
||||||
|
NotifyTrusted.command(e.getPlayer(),message,denied,deoped,punished,logged);
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void NBT(InventoryCreativeEvent e) {
|
public static void NBT(InventoryCreativeEvent e) {
|
||||||
Player p = (Player) e.getWhoClicked();
|
Player p = (Player) e.getWhoClicked();
|
||||||
final ItemStack item = e.getCursor();
|
final ItemStack item = e.getCursor();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class AntiSpam {
|
|||||||
}
|
}
|
||||||
public static void handleAntiSpam(AsyncPlayerChatEvent e) {
|
public static void handleAntiSpam(AsyncPlayerChatEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
String message = e.getMessage();
|
String message = TextUtils.removeFirstColor(e.getMessage());
|
||||||
if (!heatMap.containsKey(p)) heatMap.put(p, 0);
|
if (!heatMap.containsKey(p)) heatMap.put(p, 0);
|
||||||
if (heatMap.get(p) > Config.punishHeat) {
|
if (heatMap.get(p) > Config.punishHeat) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package io.github.thetrouper.sentinel.server.functions;
|
||||||
|
|
||||||
|
import io.github.thetrouper.sentinel.server.util.TextUtils;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
public class AntiUnicode {
|
||||||
|
public static void handleAntiUnicode(AsyncPlayerChatEvent e) {
|
||||||
|
String message = TextUtils.removeFirstColor(e.getMessage());
|
||||||
|
String nonAllowed = message.replaceAll("[A-Za-z0-9\\[,./?><|\\]()*&^%$#@!~`{}:;'\"-_]", "").trim();
|
||||||
|
if (nonAllowed.length() != 0) {
|
||||||
|
e.getPlayer().sendMessage(TextUtils.prefix("§cDo not send non standard unicode in chat!"));
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ public class ProfanityFilter {
|
|||||||
}
|
}
|
||||||
public static void handleProfanityFilter(AsyncPlayerChatEvent e) {
|
public static void handleProfanityFilter(AsyncPlayerChatEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
String message = e.getMessage();
|
String message = TextUtils.removeFirstColor(e.getMessage());
|
||||||
if (!scoreMap.containsKey(p)) scoreMap.put(p, 0);
|
if (!scoreMap.containsKey(p)) scoreMap.put(p, 0);
|
||||||
if (scoreMap.get(p) > Config.punishScore) punishSwear(p,highlightProfanity(message),message);
|
if (scoreMap.get(p) > Config.punishScore) punishSwear(p,highlightProfanity(message),message);
|
||||||
String severity = ProfanityFilter.checkSeverity(message);
|
String severity = ProfanityFilter.checkSeverity(message);
|
||||||
@@ -103,7 +103,7 @@ public class ProfanityFilter {
|
|||||||
}
|
}
|
||||||
public static void blockSwear(Player player, String highlightedMSG, String origMessage, String severity) {
|
public static void blockSwear(Player player, String highlightedMSG, String origMessage, String severity) {
|
||||||
player.sendMessage(TextUtils.prefix(("§cPlease do not swear in chat! Attempting to bypass this filter will result in a mute!")));
|
player.sendMessage(TextUtils.prefix(("§cPlease do not swear in chat! Attempting to bypass this filter will result in a mute!")));
|
||||||
String hover = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n§bSeverity" + severity + "\n§7§o(click to copy)");
|
String hover = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n§bSeverity: §c" + severity + "\n§7§o(click to copy)");
|
||||||
TextComponent text = new TextComponent();
|
TextComponent text = new TextComponent();
|
||||||
text.setText(TextUtils.prefix(
|
text.setText(TextUtils.prefix(
|
||||||
("§b§n" + player.getName() + "§7 has triggered the anti-swear! §8(§c" + scoreMap.get(player) + "§7/§4" + Config.punishScore + "§8)")));
|
("§b§n" + player.getName() + "§7 has triggered the anti-swear! §8(§c" + scoreMap.get(player) + "§7/§4" + Config.punishScore + "§8)")));
|
||||||
|
|||||||
@@ -37,6 +37,18 @@ public class NotifyConsole {
|
|||||||
);
|
);
|
||||||
Sentinel.log.info(log);
|
Sentinel.log.info(log);
|
||||||
}
|
}
|
||||||
|
public static void logged(Player p, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
|
||||||
|
final String log = (
|
||||||
|
"A logged command has been executed. \n]==-- Sentinel --==[" +
|
||||||
|
"\nPlayer: " + p.getName() +
|
||||||
|
"\nCommand: " + command +
|
||||||
|
"\nDenied: " + TextUtils.boolString(denied,"\u2714","\u2718") +
|
||||||
|
"\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
|
||||||
|
"\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
|
||||||
|
"\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
|
||||||
|
);
|
||||||
|
Sentinel.log.info(log);
|
||||||
|
}
|
||||||
public static void NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged) {
|
public static void NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged) {
|
||||||
String log = (
|
String log = (
|
||||||
"Sentinel caught a dangerous NBT! \n]==-- Sentinel --==[" +
|
"Sentinel caught a dangerous NBT! \n]==-- Sentinel --==[" +
|
||||||
|
|||||||
@@ -74,6 +74,35 @@ public class NotifyDiscord {
|
|||||||
Sentinel.log.info(e.toString());
|
Sentinel.log.info(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void logged(Player player, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
|
||||||
|
ServerUtils.sendDebugMessage("Creating logged Webhook...");
|
||||||
|
DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
|
||||||
|
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png");
|
||||||
|
webhook.setUsername("Sentinel Anti-Nuke | Logs");
|
||||||
|
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
|
||||||
|
.setAuthor("Sentinel Logged Commands","","")
|
||||||
|
.setTitle("General Command Log")
|
||||||
|
.setDescription(
|
||||||
|
Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\\n" +
|
||||||
|
Emojis.rightSort + " **Command:** " + command + " " + Emojis.nuke + "\\n"
|
||||||
|
)
|
||||||
|
.addField("Actions:",
|
||||||
|
Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n" +
|
||||||
|
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n" +
|
||||||
|
Emojis.rightSort + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n" +
|
||||||
|
Emojis.rightSort + "**Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
|
||||||
|
)
|
||||||
|
.setThumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay")
|
||||||
|
.setColor(Color.RED);
|
||||||
|
webhook.addEmbed(embed);
|
||||||
|
try {
|
||||||
|
ServerUtils.sendDebugMessage("Executing webhook...");
|
||||||
|
webhook.execute();
|
||||||
|
} catch (IOException e) {
|
||||||
|
ServerUtils.sendDebugMessage(TextUtils.prefix("Epic webhook failure!!!"));
|
||||||
|
Sentinel.log.info(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void NBT(Player player, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged, String logFileName) {
|
public static void NBT(Player player, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged, String logFileName) {
|
||||||
ServerUtils.sendDebugMessage("Creating NBT Webhook...");
|
ServerUtils.sendDebugMessage("Creating NBT Webhook...");
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,25 @@ public class NotifyTrusted {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void logged(Player p, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
|
||||||
|
TextComponent notification = new TextComponent(TextUtils.prefix("§b§n" + p.getName() + "§7 Has just executed a logged command!"));
|
||||||
|
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||||
|
"§8]==-- §d§lSentinel §8--==[" +
|
||||||
|
"\n§bPlayer: §f" + p.getName() +
|
||||||
|
"\n§bCommand: §f" + command +
|
||||||
|
"\n§bDenied: " + TextUtils.boolString(denied,"§a\u2714","§c\u2718") +
|
||||||
|
"\n§bDeoped: " + TextUtils.boolString(deoped,"§a\u2714","§c\u2718") +
|
||||||
|
"\n§bPunished: " + TextUtils.boolString(punished,"§a\u2714","§c\u2718") +
|
||||||
|
"\n§bLogged: " + TextUtils.boolString(logged,"§a\u2714","§c\u2718")
|
||||||
|
|
||||||
|
)));
|
||||||
|
|
||||||
|
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (Sentinel.isTrusted(trustedPlayer)) {
|
||||||
|
trustedPlayer.spigot().sendMessage(notification);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged) {
|
public static void NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged) {
|
||||||
TextComponent notification = new TextComponent(TextUtils.prefix("§b§n" + p.getName() + "§7 Has just attempted to use a dangerous NBT item!"));
|
TextComponent notification = new TextComponent(TextUtils.prefix("§b§n" + p.getName() + "§7 Has just attempted to use a dangerous NBT item!"));
|
||||||
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||||
|
|||||||
@@ -15,6 +15,17 @@ public class TextUtils {
|
|||||||
String prefix = Sentinel.prefix;
|
String prefix = Sentinel.prefix;
|
||||||
return prefix + text;
|
return prefix + text;
|
||||||
}
|
}
|
||||||
|
public static String removeFirstColor(String input) {
|
||||||
|
if (input.startsWith("§")) {
|
||||||
|
if (input.length() > 2) {
|
||||||
|
return input.substring(2);
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
public static String replaceRepeatingLetters(String message) {
|
public static String replaceRepeatingLetters(String message) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
char prevChar = '\0';
|
char prevChar = '\0';
|
||||||
@@ -32,7 +43,6 @@ public class TextUtils {
|
|||||||
result.append(c);
|
result.append(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
public static String fromLeetString(String s) {
|
public static String fromLeetString(String s) {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ authors: [ TheTrouper ]
|
|||||||
description: Detect Block and Ban players who attempt to grief your server.
|
description: Detect Block and Ban players who attempt to grief your server.
|
||||||
website: https://thetrouper.github.io/
|
website: https://thetrouper.github.io/
|
||||||
permissions:
|
permissions:
|
||||||
sentinel.info:
|
sentinel.debug:
|
||||||
description: Permission to view sentinel info
|
description: Permission to use debug commands
|
||||||
default: op
|
default: op
|
||||||
sentinel.staff:
|
sentinel.staff:
|
||||||
description: Receive anti-swear and anti-spam warnings
|
description: Receive anti-swear and anti-spam warnings
|
||||||
|
|||||||
Reference in New Issue
Block a user