From 5ec62505700fea6a8a0a59175954efe689dcdbcf Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Wed, 16 Aug 2023 18:04:24 +0700 Subject: [PATCH] racism bad --- .../chipmunk/chipmunkmod/modules/CustomChat.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java b/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java index 2018f25..fa8ce1e 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java +++ b/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java @@ -11,12 +11,18 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.text.Text; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class CustomChat { private final MinecraftClient client; 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 String format; @@ -36,6 +42,14 @@ public class CustomChat { public void chat (String message) { final ClientPlayerEntity player = client.player; + + final Matcher racistMatcher = RACIST_PATTERN.matcher(message); + if (racistMatcher.find()) { + player.sendMessage(Text.literal("racism bad")); + + return; + } + if (!enabled || !player.hasPermissionLevel(2) || !player.isCreative()) { final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler(); networkHandler.sendChatMessage(message);