forked from ChomeNS/chipmunkmod
naH
This commit is contained in:
parent
a153b0befb
commit
e4b1f66bb3
3 changed files with 30 additions and 1 deletions
|
@ -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<ClientDynamicRegistryType> combinedDynamicRegistries;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue