refactor: remove racist filter

This commit is contained in:
Chayapak Supasakul 2024-12-29 07:32:34 +07:00
parent 86ebdb1eea
commit 6264013c6b
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA

View file

@ -26,8 +26,6 @@ public class CustomChat {
public static final CustomChat INSTANCE = new CustomChat(MinecraftClient.getInstance()); public static final CustomChat INSTANCE = new CustomChat(MinecraftClient.getInstance());
public static final Pattern RACIST_PATTERN = Pattern.compile("nigga|nigger|i hate black", Pattern.CASE_INSENSITIVE);
public boolean enabled = true; public boolean enabled = true;
public String format; public String format;
@ -85,16 +83,7 @@ public class CustomChat {
public void chat (String message) { public void chat (String message) {
final ClientPlayerEntity player = client.player; final ClientPlayerEntity player = client.player;
try { if (player != null) return;
final Matcher racistMatcher = RACIST_PATTERN.matcher(message);
if (racistMatcher.matches()) {
player.sendMessage(Text.literal("racism bad"), false);
return;
}
} catch (Exception e) {
e.printStackTrace();
}
if (!enabled || !player.hasPermissionLevel(2) || !player.isCreative()) { if (!enabled || !player.hasPermissionLevel(2) || !player.isCreative()) {
Chat.sendChatMessage(message, true); Chat.sendChatMessage(message, true);
@ -147,7 +136,7 @@ public class CustomChat {
CommandCore.INSTANCE.run((KaboomCheck.INSTANCE.isKaboom ? "minecraft:tellraw @a " : "tellraw @a ") + sanitizedFormat); CommandCore.INSTANCE.run((KaboomCheck.INSTANCE.isKaboom ? "minecraft:tellraw @a " : "tellraw @a ") + sanitizedFormat);
} catch (Exception e) { } catch (Exception e) {
if (client.player == null) return; if (client.player == null) return;
((Audience) client.player).sendMessage(Component.text(e.toString()).color(NamedTextColor.RED)); client.player.sendMessage(Component.text(e.toString()).color(NamedTextColor.RED));
} }
} }
} }