diff --git a/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientPlayNetworkHandlerMixin.java index 41dd707..efbef93 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientPlayNetworkHandlerMixin.java @@ -37,7 +37,7 @@ import java.io.OutputStream; import java.net.URL; import java.util.List; -@Mixin(value = net.minecraft.client.network.ClientPlayNetworkHandler.class, priority = 1024) +@Mixin(value = net.minecraft.client.network.ClientPlayNetworkHandler.class, priority = 1001) public class ClientPlayNetworkHandlerMixin { @Shadow private FeatureSet enabledFeatures; @Shadow private CombinedDynamicRegistries combinedDynamicRegistries; diff --git a/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java b/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java index c7fb7b0..0e8cdad 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java +++ b/src/main/java/land/chipmunk/chipmunkmod/modules/CustomChat.java @@ -2,6 +2,9 @@ package land.chipmunk.chipmunkmod.modules; import com.google.gson.JsonElement; import land.chipmunk.chipmunkmod.ChipmunkMod; + + +import land.chipmunk.chipmunkmod.commands.SayCommand; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; @@ -9,12 +12,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; @@ -35,9 +44,22 @@ public class CustomChat { public void chat (String message) { final ClientPlayerEntity player = client.player; + try { + final Matcher racistMatcher = RACIST_PATTERN.matcher(message); + if (racistMatcher.matches()) { + player.sendMessage(Text.literal("racism bad")); + + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + if (!enabled || !player.hasPermissionLevel(2) || !player.isCreative()) { final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler(); + SayCommand.saying = true; networkHandler.sendChatMessage(message); + SayCommand.saying = false; return; } diff --git a/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java b/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java index b149d64..5292378 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java +++ b/src/main/java/land/chipmunk/chipmunkmod/util/BotValidationUtilities.java @@ -3,6 +3,7 @@ package land.chipmunk.chipmunkmod.util; import com.mojang.brigadier.Command; import land.chipmunk.chipmunkmod.ChipmunkMod; import land.chipmunk.chipmunkmod.Configuration; +import land.chipmunk.chipmunkmod.commands.SayCommand; import land.chipmunk.chipmunkmod.modules.CustomChat; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; @@ -32,7 +33,9 @@ public class BotValidationUtilities { BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4)); String stringHash = bigInt.toString(Character.MAX_RADIX); + SayCommand.saying = true; networkHandler.sendChatMessage(prefix + command + " " + stringHash); + SayCommand.saying = false; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } @@ -57,7 +60,9 @@ public class BotValidationUtilities { BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4)); String stringHash = bigInt.toString(Character.MAX_RADIX); + SayCommand.saying = true; networkHandler.sendChatMessage(prefix + command + " " + stringHash); + SayCommand.saying = false; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } @@ -129,7 +134,9 @@ public class BotValidationUtilities { BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4)); String stringHash = bigInt.toString(Character.MAX_RADIX); + SayCommand.saying = true; networkHandler.sendChatMessage(prefix + command + " " + stringHash); + SayCommand.saying = false; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); }