add clearing chat of DMs

This commit is contained in:
Daniella / Tove 2024-05-27 04:58:43 +02:00
parent 6232f12527
commit 5f919e4a04

View file

@ -3,13 +3,18 @@ package com.baseband.client.module.chat;
import com.baseband.client.configuration.annotation.Config;
import com.baseband.client.configuration.annotation.Gate;
import com.baseband.client.event.events.PacketEvent;
import com.baseband.client.gui.lib.component.Button;
import com.baseband.client.module.Feature;
import com.baseband.client.module.category.Chat;
import com.baseband.client.util.misc.FieldFinder;
import com.baseband.client.util.misc.Marker;
import com.baseband.client.util.ingame.ChatUtil;
import net.minecraft.client.gui.ChatLine;
import net.minecraft.client.gui.GuiNewChat;
import net.minecraft.network.play.server.SPacketChat;
import net.minecraft.util.text.TextComponentString;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -39,6 +44,25 @@ public class ExtraChat extends Feature {
@Config("InfiniteChat")
public boolean infinitechat;
@Config("DM regex")
public String dmRegex = "^((To|From|You whisper to) \\w+|\\w+ whispers to you): .*$";
@Config("Remove DMs now")
public Button.ClickEvent event = btn -> {
List<ChatLine> chatLines;
try {
chatLines = (List<ChatLine>) FieldFinder.findUnmarked(GuiNewChat.class, List.class, 1).get(mc.ingameGUI.getChatGUI());
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
for (int i = 0; i < chatLines.size(); i++) {
if(chatLines.get(i).getChatComponent().getUnformattedText().matches(dmRegex))
chatLines.remove(i--);
}
mc.ingameGUI.getChatGUI().refreshChat();
ChatUtil.print("Cleared chat of DMs");
};
public void onChat(PacketEvent.Read event) {
if (event.getPacket() instanceof SPacketChat && antiPopLag) {