chat history: support clan chat

Additionally fix the TAB_PRIVATE widget mapping which is incorrect with the
latest update. The old friends chat tab has also gained a Clear history
option so we no longer need to add it.
This commit is contained in:
Adam
2021-05-23 00:03:34 -04:00
parent 903e73f9f6
commit 945f0b6d77
5 changed files with 31 additions and 4 deletions

View File

@@ -37,6 +37,7 @@ import java.util.Deque;
import java.util.Iterator;
import java.util.Queue;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatLineBuffer;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
@@ -72,6 +73,7 @@ import org.apache.commons.lang3.StringUtils;
description = "Retain your chat history when logging in/out or world hopping",
tags = {"chat", "history", "retain", "cycle", "pm"}
)
@Slf4j
public class ChatHistoryPlugin extends Plugin implements KeyListener
{
private static final String WELCOME_MESSAGE = "Welcome to Old School RuneScape";
@@ -173,6 +175,8 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
case PUBLICCHAT:
case MODCHAT:
case FRIENDSCHAT:
case CLANCHANNEL_LISTENED:
case CLANCHANNEL_AFFINED:
case CONSOLE:
messageQueue.offer(chatMessage.getMessageNode());
}
@@ -262,7 +266,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
{
final ChatboxTab tab = ChatboxTab.of(entry.getActionParam1());
if (tab == null || !config.clearHistory() || !Text.removeTags(entry.getOption()).equals(tab.getAfter()))
if (tab == null || tab.getAfter() == null || !config.clearHistory() || !Text.removeTags(entry.getOption()).equals(tab.getAfter()))
{
return;
}
@@ -311,6 +315,8 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
return;
}
log.debug("Clearing chatbox history for tab {}", tab);
boolean removed = false;
for (ChatMessageType msgType : tab.getMessageTypes())
{

View File

@@ -54,10 +54,13 @@ enum ChatboxTab
ChatMessageType.CONSOLE, ChatMessageType.SPAM, ChatMessageType.PLAYERRELATED, ChatMessageType.TENSECTIMEOUT,
ChatMessageType.WELCOME, ChatMessageType.UNKNOWN),
CLAN("Clan", "Clan: Off", WidgetInfo.CHATBOX_TAB_CLAN,
CHANNEL("Channel", null, WidgetInfo.CHATBOX_TAB_CHANNEL,
ChatMessageType.FRIENDSCHATNOTIFICATION, ChatMessageType.FRIENDSCHAT, ChatMessageType.CHALREQ_FRIENDSCHAT),
TRADE("Trade", "Trade: Off", WidgetInfo.CHATBOX_TAB_TRADE,
CLAN("Clan", null, WidgetInfo.CHATBOX_TAB_CLAN,
ChatMessageType.CLANCHANNEL_AFFINED, ChatMessageType.CLANCHANNEL_SYSTEM_AFFINED, ChatMessageType.CLANCHANNEL_LISTENED, ChatMessageType.CLANCHANNEL_SYSTEM_LISTENED),
TRADE("Trade", "Trade: Show none", WidgetInfo.CHATBOX_TAB_TRADE,
ChatMessageType.TRADE_SENT, ChatMessageType.TRADEREQ, ChatMessageType.TRADE, ChatMessageType.CHALREQ_TRADE),
;