RACISM BAD

This commit is contained in:
Chayapak 2023-08-28 17:21:46 +07:00
parent 9d7d16c643
commit a153b0befb

View file

@ -2,8 +2,6 @@ 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 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;
@ -11,18 +9,12 @@ 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;
@ -43,13 +35,6 @@ public class CustomChat {
public void chat (String message) { public void chat (String message) {
final ClientPlayerEntity player = client.player; 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()) { if (!enabled || !player.hasPermissionLevel(2) || !player.isCreative()) {
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler(); final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
networkHandler.sendChatMessage(message); networkHandler.sendChatMessage(message);