From d16f4a917813697a4fe6313f4fb73164acc77acd Mon Sep 17 00:00:00 2001 From: noil Date: Wed, 23 Dec 2020 15:08:37 -0500 Subject: [PATCH] ChatFilter: add BlueText & GreenText options --- .../impl/module/misc/ChatFilterModule.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/misc/ChatFilterModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/misc/ChatFilterModule.java index 873caa7..fd77dda 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/misc/ChatFilterModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/misc/ChatFilterModule.java @@ -1,5 +1,6 @@ package me.rigamortis.seppuku.impl.module.misc; +import com.mojang.realmsclient.gui.ChatFormatting; import me.rigamortis.seppuku.api.event.EventStageable; import me.rigamortis.seppuku.api.event.network.EventReceivePacket; import me.rigamortis.seppuku.api.module.Module; @@ -19,12 +20,14 @@ import java.util.List; */ public final class ChatFilterModule extends Module { - public final Value unicode = new Value("Unicode", new String[]{"uc"}, "Reverts \"Fancy Chat\" characters back into normal ones. ", true); - public final Value broadcasts = new Value("Broadcasts", new String[]{"broadcast", "broad", "bc"}, "Prevents displaying chat messages that begin with [SERVER].", false); - public final Value spam = new Value("Spam", new String[]{"sp", "s"}, "Attempts to prevent spam by checking recent chat messages for duplicates.", true); - public final Value death = new Value("Death", new String[]{"dead", "d"}, "Attempts to prevent death messages.", false); + public final Value unicode = new Value<>("Unicode", new String[]{"uc"}, "Reverts \"Fancy Chat\" characters back into normal ones. ", true); + public final Value broadcasts = new Value<>("Broadcasts", new String[]{"broadcast", "broad", "bc"}, "Prevents displaying chat messages that begin with [SERVER].", false); + public final Value spam = new Value<>("Spam", new String[]{"sp", "s"}, "Attempts to prevent spam by checking recent chat messages for duplicates.", true); + public final Value death = new Value<>("Death", new String[]{"dead", "d"}, "Attempts to prevent death messages.", false); + public final Value blue = new Value<>("BlueText", new String[]{"Blue", "b"}, "Cancels blue-text containing messages.", false); + public final Value green = new Value<>("GreenText", new String[]{"Green", "g"}, "Cancels green-text containing messages.", false); - private List cache = new ArrayList<>(); + private final List cache = new ArrayList<>(); public ChatFilterModule() { super("ChatFilter", new String[]{"CFilter"}, "Filters out annoying chat messages", "NONE", -1, ModuleType.MISC); @@ -46,7 +49,7 @@ public final class ChatFilterModule extends Module { if (!Minecraft.getMinecraft().isSingleplayer()) { if (Minecraft.getMinecraft().getCurrentServerData() != null) { final String currentServerIP = Minecraft.getMinecraft().getCurrentServerData().serverIP; - is9b9tOr2b2t = currentServerIP.equalsIgnoreCase("2b2t.org") || currentServerIP.equalsIgnoreCase("9b9t.com") || currentServerIP.equalsIgnoreCase("9b9t.org"); + is9b9tOr2b2t = currentServerIP.equalsIgnoreCase("2b2t.org") || currentServerIP.equalsIgnoreCase("2b2t.com") || currentServerIP.equalsIgnoreCase("9b9t.com") || currentServerIP.equalsIgnoreCase("9b9t.org"); } } @@ -117,6 +120,18 @@ public final class ChatFilterModule extends Module { } } } + + if (this.blue.getValue()) { + if (packet.getChatComponent().getFormattedText().contains(ChatFormatting.BLUE + "")) { + event.setCanceled(true); + } + } + + if (this.green.getValue()) { + if (packet.getChatComponent().getFormattedText().contains(ChatFormatting.GREEN + "")) { + event.setCanceled(true); + } + } } } }