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.net.URL;
|
||||||
import java.util.List;
|
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 {
|
public class ClientPlayNetworkHandlerMixin {
|
||||||
@Shadow private FeatureSet enabledFeatures;
|
@Shadow private FeatureSet enabledFeatures;
|
||||||
@Shadow private CombinedDynamicRegistries<ClientDynamicRegistryType> combinedDynamicRegistries;
|
@Shadow private CombinedDynamicRegistries<ClientDynamicRegistryType> combinedDynamicRegistries;
|
||||||
|
|
|
@ -2,6 +2,9 @@ package land.chipmunk.chipmunkmod.modules;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||||
|
|
||||||
|
|
||||||
|
import land.chipmunk.chipmunkmod.commands.SayCommand;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
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.MinecraftClient;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class CustomChat {
|
public class CustomChat {
|
||||||
private final MinecraftClient client;
|
private final MinecraftClient client;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -35,9 +44,22 @@ public class CustomChat {
|
||||||
public void chat (String message) {
|
public void chat (String message) {
|
||||||
final ClientPlayerEntity player = client.player;
|
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()) {
|
if (!enabled || !player.hasPermissionLevel(2) || !player.isCreative()) {
|
||||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||||
|
SayCommand.saying = true;
|
||||||
networkHandler.sendChatMessage(message);
|
networkHandler.sendChatMessage(message);
|
||||||
|
SayCommand.saying = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package land.chipmunk.chipmunkmod.util;
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||||
import land.chipmunk.chipmunkmod.Configuration;
|
import land.chipmunk.chipmunkmod.Configuration;
|
||||||
|
import land.chipmunk.chipmunkmod.commands.SayCommand;
|
||||||
import land.chipmunk.chipmunkmod.modules.CustomChat;
|
import land.chipmunk.chipmunkmod.modules.CustomChat;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
|
@ -32,7 +33,9 @@ public class BotValidationUtilities {
|
||||||
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
||||||
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
||||||
|
|
||||||
|
SayCommand.saying = true;
|
||||||
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
||||||
|
SayCommand.saying = false;
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +60,9 @@ public class BotValidationUtilities {
|
||||||
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
||||||
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
||||||
|
|
||||||
|
SayCommand.saying = true;
|
||||||
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
||||||
|
SayCommand.saying = false;
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -129,7 +134,9 @@ public class BotValidationUtilities {
|
||||||
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
||||||
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
||||||
|
|
||||||
|
SayCommand.saying = true;
|
||||||
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
||||||
|
SayCommand.saying = false;
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue