antiswear leet string checks
This commit is contained in:
@@ -3,6 +3,7 @@ package fun.ogre.ogredupealias.plugin;
|
|||||||
import fun.ogre.ogredupealias.data.Config;
|
import fun.ogre.ogredupealias.data.Config;
|
||||||
import fun.ogre.ogredupealias.utils.ArrayUtils;
|
import fun.ogre.ogredupealias.utils.ArrayUtils;
|
||||||
import fun.ogre.ogredupealias.utils.ServerUtils;
|
import fun.ogre.ogredupealias.utils.ServerUtils;
|
||||||
|
import fun.ogre.ogredupealias.utils.StringUtils;
|
||||||
import fun.ogre.ogredupealias.utils.Text;
|
import fun.ogre.ogredupealias.utils.Text;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
@@ -88,7 +89,8 @@ public class ChatConstraints {
|
|||||||
if (player.hasPermission("oda.chat.bypass.swear")) return true;
|
if (player.hasPermission("oda.chat.bypass.swear")) return true;
|
||||||
|
|
||||||
// 1
|
// 1
|
||||||
String msg = message.replaceAll("[^A-Za-z0-9]", "").trim();
|
String msg = StringUtils.fromLeetString(message);
|
||||||
|
msg = msg.replaceAll("[^A-Za-z0-9]", "").trim();
|
||||||
// 2
|
// 2
|
||||||
msg = msg.toLowerCase();
|
msg = msg.toLowerCase();
|
||||||
// 3
|
// 3
|
||||||
@@ -110,7 +112,7 @@ public class ChatConstraints {
|
|||||||
if (!flags.isEmpty()) {
|
if (!flags.isEmpty()) {
|
||||||
player.sendMessage(Text.ofAll("&cPlease do not swear in chat! Attempting to bypass this filter would result in a mute!"));
|
player.sendMessage(Text.ofAll("&cPlease do not swear in chat! Attempting to bypass this filter would result in a mute!"));
|
||||||
// 7
|
// 7
|
||||||
String hover = Text.color("&bMessage: &f" + msg + "\n&bFlags: &f" + ArrayUtils.list2string(flags) + "\n&7&o(click to copy)");
|
String hover = Text.color("&bOriginal: &f" + this.message + "\n&bMessage: &f" + msg + "\n&bFlags: &f" + ArrayUtils.list2string(flags) + "\n&7&o(click to copy)");
|
||||||
TextComponent text = new TextComponent();
|
TextComponent text = new TextComponent();
|
||||||
text.setText(Text.ofAll("&f&n" + player.getName() + "&e has triggered the anti-swear!"));
|
text.setText(Text.ofAll("&f&n" + player.getName() + "&e has triggered the anti-swear!"));
|
||||||
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
|
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
|
||||||
|
|||||||
@@ -15,4 +15,20 @@ public final class StringUtils {
|
|||||||
for (String str : sArray) sb.append(capitalize(str)).append(" ");
|
for (String str : sArray) sb.append(capitalize(str)).append(" ");
|
||||||
return sb.toString().trim();
|
return sb.toString().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String fromLeetString(String s) {
|
||||||
|
return s.replaceAll("0", "o")
|
||||||
|
.replaceAll("1", "i")
|
||||||
|
.replaceAll("3", "e")
|
||||||
|
.replaceAll("4", "a")
|
||||||
|
.replaceAll("5", "s")
|
||||||
|
.replaceAll("7", "l")
|
||||||
|
.replaceAll("\\$", "s")
|
||||||
|
.replaceAll("!", "i")
|
||||||
|
.replaceAll("\\+", "t")
|
||||||
|
.replaceAll("#", "h")
|
||||||
|
.replaceAll("@", "a")
|
||||||
|
.replaceAll("<", "c")
|
||||||
|
.replaceAll("v", "u");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user