add clearing chat of DMs
This commit is contained in:
parent
6232f12527
commit
5f919e4a04
1 changed files with 24 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue