From 903e73f9f6d7ebe3c946445205f292bb3abcd265 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 21 May 2021 13:26:22 -0400 Subject: [PATCH 01/15] twitch: change chat trigger to /t // was taken by clan chat with the recent update --- .../java/net/runelite/client/plugins/twitch/TwitchPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java index 42bc99809f..e5ed6a613b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java @@ -211,9 +211,9 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput public boolean onChatboxInput(ChatboxInput chatboxInput) { String message = chatboxInput.getValue(); - if (message.startsWith("//")) + if (message.startsWith("/t ")) { - message = message.substring(2); + message = message.substring(3); if (message.isEmpty() || twitchIRCClient == null) { return true; From 945f0b6d77058b55f658817b7e5017a8510113c0 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 23 May 2021 00:03:34 -0400 Subject: [PATCH 02/15] 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. --- .../java/net/runelite/api/ChatMessageType.java | 16 ++++++++++++++++ .../java/net/runelite/api/widgets/WidgetID.java | 3 ++- .../net/runelite/api/widgets/WidgetInfo.java | 1 + .../plugins/chathistory/ChatHistoryPlugin.java | 8 +++++++- .../client/plugins/chathistory/ChatboxTab.java | 7 +++++-- 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/ChatMessageType.java b/runelite-api/src/main/java/net/runelite/api/ChatMessageType.java index d453bfbb35..c54283ad74 100644 --- a/runelite-api/src/main/java/net/runelite/api/ChatMessageType.java +++ b/runelite-api/src/main/java/net/runelite/api/ChatMessageType.java @@ -108,6 +108,22 @@ public enum ChatMessageType * Adding player to ignore list. */ IGNORENOTIFICATION(31), + /** + * A chat message in a guest clan chat. + */ + CLANCHANNEL_AFFINED(41), + /** + * A system message in a guest clan chat. + */ + CLANCHANNEL_SYSTEM_AFFINED(43), + /** + * A chat message in the primary clan chat. + */ + CLANCHANNEL_LISTENED(44), + /** + * A system message in the primary clan chat. + */ + CLANCHANNEL_SYSTEM_LISTENED(46), /** * An autotyper message from a player. */ diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java index dcb59909b2..4147caa8b8 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java @@ -480,7 +480,8 @@ public class WidgetID static final int TAB_ALL = 4; static final int TAB_GAME = 7; static final int TAB_PUBLIC = 11; - static final int TAB_PRIVATE = 19; + static final int TAB_PRIVATE = 15; + static final int TAB_CHANNEL = 19; static final int TAB_CLAN = 23; static final int TAB_TRADE = 27; static final int REPORT_TEXT = 33; diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java index 328c289f61..82de501e75 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java @@ -366,6 +366,7 @@ public enum WidgetInfo CHATBOX_TAB_GAME(WidgetID.CHATBOX_GROUP_ID, WidgetID.Chatbox.TAB_GAME), CHATBOX_TAB_PUBLIC(WidgetID.CHATBOX_GROUP_ID, WidgetID.Chatbox.TAB_PUBLIC), CHATBOX_TAB_PRIVATE(WidgetID.CHATBOX_GROUP_ID, WidgetID.Chatbox.TAB_PRIVATE), + CHATBOX_TAB_CHANNEL(WidgetID.CHATBOX_GROUP_ID, WidgetID.Chatbox.TAB_CHANNEL), CHATBOX_TAB_CLAN(WidgetID.CHATBOX_GROUP_ID, WidgetID.Chatbox.TAB_CLAN), CHATBOX_TAB_TRADE(WidgetID.CHATBOX_GROUP_ID, WidgetID.Chatbox.TAB_TRADE), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java index cc94cfc801..e656d70a6e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java @@ -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()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatboxTab.java b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatboxTab.java index f37adb0ea1..d833e4e131 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatboxTab.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatboxTab.java @@ -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), ; From b5375ae48756555bec35ee043701d93687c366ae Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 23 May 2021 11:10:54 -0400 Subject: [PATCH 03/15] chat history: rebuild pmbox when all is cleared Additionally it is unnecessary to manually remove messages when the clear option is vanilla, since it will do it already --- .../src/main/java/net/runelite/api/ScriptID.java | 6 ++++++ .../plugins/chathistory/ChatHistoryPlugin.java | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/ScriptID.java b/runelite-api/src/main/java/net/runelite/api/ScriptID.java index 0f8853841b..5d294709b8 100644 --- a/runelite-api/src/main/java/net/runelite/api/ScriptID.java +++ b/runelite-api/src/main/java/net/runelite/api/ScriptID.java @@ -47,6 +47,12 @@ public final class ScriptID @ScriptArguments(integer = 1, string = 1) public static final int CHATBOX_INPUT = 96; + /** + * Rebuilds the chatbox and the pmbox + */ + @ScriptArguments() + public static final int SPLITPM_CHANGED = 83; + /** * Rebuilds the chatbox */ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java index e656d70a6e..1aa16ee6cc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java @@ -317,6 +317,14 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener log.debug("Clearing chatbox history for tab {}", tab); + clearMessageQueue(tab); + + if (tab.getAfter() == null) + { + // if the tab has a vanilla Clear option, it isn't necessary to delete the messages ourselves. + return; + } + boolean removed = false; for (ChatMessageType msgType : tab.getMessageTypes()) { @@ -339,10 +347,9 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener if (removed) { - clientThread.invoke(() -> client.runScript(ScriptID.BUILD_CHATBOX)); + // this rebuilds both the chatbox and the pmbox + clientThread.invoke(() -> client.runScript(ScriptID.SPLITPM_CHANGED)); } - - clearMessageQueue(tab); } @Override From ed5d3593203d38482e4ee6d42e681df6af40f290 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 23 May 2021 13:57:02 -0400 Subject: [PATCH 04/15] api: add getOnVarTransmitListener to Widget --- .../src/main/java/net/runelite/api/widgets/Widget.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java b/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java index 979a9500a0..1c1f02193a 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/Widget.java @@ -999,6 +999,13 @@ public interface Widget */ void setDragParent(Widget dragParent); + /** + * Gets the script and arguments to be ran when one of the listened for vars changes. + * + * @return + */ + Object[] getOnVarTransmitListener(); + /** * Sets a script to be ran when a varplayer changes * From 5de8eee04d3a47b42b8a4baf6a4ba272adc890ac Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 23 May 2021 13:34:54 -0400 Subject: [PATCH 05/15] friendschat: readd user count Also readd the Recent FCs title --- .../net/runelite/api/widgets/WidgetID.java | 2 + .../net/runelite/api/widgets/WidgetInfo.java | 2 + .../friendschat/FriendsChatPlugin.java | 38 ++++++++++++------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java index 4147caa8b8..7bca04ced4 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java @@ -251,6 +251,8 @@ public class WidgetID static class FriendsChat { + static final int ROOT = 0; + static final int TITLE = 1; static final int OWNER = 2; static final int LIST = 12; } diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java index 82de501e75..c86678fdff 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java @@ -126,6 +126,8 @@ public enum WidgetInfo EXPLORERS_RING_ALCH_INVENTORY(WidgetID.EXPLORERS_RING_ALCH_GROUP_ID, WidgetID.ExplorersRing.INVENTORY), + FRIENDS_CHAT_ROOT(WidgetID.FRIENDS_CHAT_GROUP_ID, WidgetID.FriendsChat.ROOT), + FRIENDS_CHAT_TITLE(WidgetID.FRIENDS_CHAT_GROUP_ID, WidgetID.FriendsChat.TITLE), FRIENDS_CHAT_OWNER(WidgetID.FRIENDS_CHAT_GROUP_ID, WidgetID.FriendsChat.OWNER), FRIENDS_CHAT_LIST(WidgetID.FRIENDS_CHAT_GROUP_ID, WidgetID.FriendsChat.LIST), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/friendschat/FriendsChatPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/friendschat/FriendsChatPlugin.java index c851c05697..2f6eb086a3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/friendschat/FriendsChatPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/friendschat/FriendsChatPlugin.java @@ -96,6 +96,7 @@ import net.runelite.client.util.Text; public class FriendsChatPlugin extends Plugin { private static final int MAX_CHATS = 10; + private static final String RECENT_TITLE = "Recent FCs"; private static final int MESSAGE_DELAY = 10; @Inject @@ -157,7 +158,7 @@ public class FriendsChatPlugin extends Plugin clientThread.invoke(() -> colorIgnoredPlayers(Color.WHITE)); members.clear(); resetCounter(); - resetChats(); + rebuildFriendsChat(); } @Subscribe @@ -167,7 +168,7 @@ public class FriendsChatPlugin extends Plugin { if (!config.recentChats()) { - resetChats(); + rebuildFriendsChat(); } if (config.showCounter()) @@ -556,9 +557,19 @@ public class FriendsChatPlugin extends Plugin @Subscribe public void onScriptPostFired(ScriptPostFired event) { - if (event.getScriptId() == ScriptID.FRIENDS_CHAT_CHANNEL_REBUILD && config.showIgnores()) + if (event.getScriptId() == ScriptID.FRIENDS_CHAT_CHANNEL_REBUILD) { - colorIgnoredPlayers(config.showIgnoresColor()); + if (config.showIgnores()) + { + colorIgnoredPlayers(config.showIgnoresColor()); + } + + FriendsChatManager friendsChatManager = client.getFriendsChatManager(); + Widget chatTitle = client.getWidget(WidgetInfo.FRIENDS_CHAT_TITLE); + if (friendsChatManager != null && friendsChatManager.getCount() > 0 && chatTitle != null) + { + chatTitle.setText(chatTitle.getText() + " (" + friendsChatManager.getCount() + "/100)"); + } } } @@ -589,30 +600,29 @@ public class FriendsChatPlugin extends Plugin } } - private void resetChats() + private void rebuildFriendsChat() { - Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST); - - if (chatList == null) + Widget chat = client.getWidget(WidgetInfo.FRIENDS_CHAT_ROOT); + if (chat == null) { return; } - FriendsChatManager friendsChatManager = client.getFriendsChatManager(); - if (friendsChatManager == null || friendsChatManager.getCount() == 0) - { - chatList.setChildren(null); - } + Object[] args = chat.getOnVarTransmitListener(); + clientThread.invokeLater(() -> client.runScript(args)); } private void loadFriendsChats() { + Widget chatOwner = client.getWidget(WidgetInfo.FRIENDS_CHAT_OWNER); Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST); - if (chatList == null) + if (chatList == null || chatOwner == null) { return; } + chatOwner.setText(RECENT_TITLE); + int y = 2; chatList.setChildren(null); for (String chat : Lists.reverse(chats)) From ff86846d5db7488eb74af0feb4fde210449d5998 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 May 2021 23:23:32 -0400 Subject: [PATCH 06/15] api: add enum size --- .../src/main/java/net/runelite/api/EnumComposition.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/EnumComposition.java b/runelite-api/src/main/java/net/runelite/api/EnumComposition.java index 00f8c30814..38f20c4887 100644 --- a/runelite-api/src/main/java/net/runelite/api/EnumComposition.java +++ b/runelite-api/src/main/java/net/runelite/api/EnumComposition.java @@ -26,6 +26,8 @@ package net.runelite.api; public interface EnumComposition { + int size(); + int[] getKeys(); int[] getIntVals(); From 21275bb9f0182dfdfd54f956c129e81e0d6e6dfd Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 May 2021 23:24:39 -0400 Subject: [PATCH 07/15] api: correct clans chattypes --- .../net/runelite/api/ChatMessageType.java | 24 ++++++++++++------- .../chathistory/ChatHistoryPlugin.java | 4 ++-- .../plugins/chathistory/ChatboxTab.java | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/ChatMessageType.java b/runelite-api/src/main/java/net/runelite/api/ChatMessageType.java index c54283ad74..9863de16d2 100644 --- a/runelite-api/src/main/java/net/runelite/api/ChatMessageType.java +++ b/runelite-api/src/main/java/net/runelite/api/ChatMessageType.java @@ -109,21 +109,21 @@ public enum ChatMessageType */ IGNORENOTIFICATION(31), /** - * A chat message in a guest clan chat. + * A chat message in a clan chat. */ - CLANCHANNEL_AFFINED(41), + CLAN_CHAT(41), /** - * A system message in a guest clan chat. + * A system message in a clan chat. */ - CLANCHANNEL_SYSTEM_AFFINED(43), + CLAN_MESSAGE(43), /** - * A chat message in the primary clan chat. + * A chat message in the guest clan chat. */ - CLANCHANNEL_LISTENED(44), + CLAN_GUEST_CHAT(44), /** - * A system message in the primary clan chat. + * A system message in the guest clan chat. */ - CLANCHANNEL_SYSTEM_LISTENED(46), + CLAN_GUEST_MESSAGE(46), /** * An autotyper message from a player. */ @@ -168,6 +168,14 @@ public enum ChatMessageType * The "Welcome to RuneScape" message */ WELCOME(108), + /** + * Clan creation invitation. + */ + CLAN_CREATION_INVITATION(109), + /** + * Clan wars challenge for clans rather than FCs + */ + CLAN_CLAN_WARS_CHALLENGE(110), /** * An unknown message type. */ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java index 1aa16ee6cc..30b0b740cd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java @@ -175,8 +175,8 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener case PUBLICCHAT: case MODCHAT: case FRIENDSCHAT: - case CLANCHANNEL_LISTENED: - case CLANCHANNEL_AFFINED: + case CLAN_GUEST_CHAT: + case CLAN_CHAT: case CONSOLE: messageQueue.offer(chatMessage.getMessageNode()); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatboxTab.java b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatboxTab.java index d833e4e131..a0ad48f287 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatboxTab.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatboxTab.java @@ -58,7 +58,7 @@ enum ChatboxTab ChatMessageType.FRIENDSCHATNOTIFICATION, ChatMessageType.FRIENDSCHAT, ChatMessageType.CHALREQ_FRIENDSCHAT), CLAN("Clan", null, WidgetInfo.CHATBOX_TAB_CLAN, - ChatMessageType.CLANCHANNEL_AFFINED, ChatMessageType.CLANCHANNEL_SYSTEM_AFFINED, ChatMessageType.CLANCHANNEL_LISTENED, ChatMessageType.CLANCHANNEL_SYSTEM_LISTENED), + ChatMessageType.CLAN_CHAT, ChatMessageType.CLAN_MESSAGE, ChatMessageType.CLAN_GUEST_CHAT, ChatMessageType.CLAN_GUEST_MESSAGE), TRADE("Trade", "Trade: Show none", WidgetInfo.CHATBOX_TAB_TRADE, ChatMessageType.TRADE_SENT, ChatMessageType.TRADEREQ, ChatMessageType.TRADE, ChatMessageType.CHALREQ_TRADE), From c72a571837b187a73fbccf071f59d3090b4c4cab Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 May 2021 23:24:56 -0400 Subject: [PATCH 08/15] devtools: add modicons command --- .../plugins/devtools/DevToolsPlugin.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java index e063da77e1..a22887b53f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsPlugin.java @@ -38,6 +38,7 @@ import lombok.Getter; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.Experience; +import net.runelite.api.IndexedSprite; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; import net.runelite.api.NPC; @@ -428,6 +429,25 @@ public class DevToolsPlugin extends Plugin .build()); break; } + case "modicons": + { + final ChatMessageBuilder builder = new ChatMessageBuilder(); + final IndexedSprite[] modIcons = client.getModIcons(); + for (int i = 0; i < modIcons.length; i++) + { + builder.append(i + "=").img(i); + + if (i != modIcons.length - 1) + { + builder.append(", "); + } + } + chatMessageManager.queue(QueuedMessage.builder() + .type(ChatMessageType.GAMEMESSAGE) + .runeLiteFormattedMessage(builder.build()) + .build()); + break; + } } } From a781efc73a706e33ebffd02cd3b36c7bdf21164a Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 May 2021 23:26:37 -0400 Subject: [PATCH 09/15] friendchatmanager: rename to chaticonmanager FriendsChatManager predates the api having an ability to look up clan members by name, without doing string matching, hence the caching. This is no longer necessary as we can do efficient lookups of players by name now. Also remove the old isMember utility function which is just duplicated from the friends chat manager. --- .../main/java/net/runelite/api/EnumID.java | 1 + ...dChatManager.java => ChatIconManager.java} | 104 ++++-------------- .../plugins/chatfilter/ChatFilterPlugin.java | 13 ++- .../friendschat/FriendsChatPlugin.java | 22 +++- .../PlayerIndicatorsOverlay.java | 16 +-- .../PlayerIndicatorsPlugin.java | 34 ++++-- .../PlayerIndicatorsService.java | 15 +++ .../chatfilter/ChatFilterPluginTest.java | 16 +-- 8 files changed, 107 insertions(+), 114 deletions(-) rename runelite-client/src/main/java/net/runelite/client/game/{FriendChatManager.java => ChatIconManager.java} (52%) diff --git a/runelite-api/src/main/java/net/runelite/api/EnumID.java b/runelite-api/src/main/java/net/runelite/api/EnumID.java index 7d836dc613..2c2fcecb87 100644 --- a/runelite-api/src/main/java/net/runelite/api/EnumID.java +++ b/runelite-api/src/main/java/net/runelite/api/EnumID.java @@ -34,4 +34,5 @@ public final class EnumID public static final int MUSIC_TRACK_NAMES = 812; public static final int MUSIC_TRACK_IDS = 819; public static final int XPDROP_COLORS = 1169; + public static final int FRIENDS_CHAT_RANK_ICONS = 1543; } diff --git a/runelite-client/src/main/java/net/runelite/client/game/FriendChatManager.java b/runelite-client/src/main/java/net/runelite/client/game/ChatIconManager.java similarity index 52% rename from runelite-client/src/main/java/net/runelite/client/game/FriendChatManager.java rename to runelite-client/src/main/java/net/runelite/client/game/ChatIconManager.java index f27eb6f312..6e80237e96 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/FriendChatManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/ChatIconManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Adam + * Copyright (c) 2021, Adam * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,94 +24,45 @@ */ package net.runelite.client.game; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; import java.awt.Color; import java.awt.Dimension; import java.awt.image.BufferedImage; import java.util.Arrays; -import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.inject.Inject; import javax.inject.Singleton; -import net.runelite.api.FriendsChatMember; -import net.runelite.api.FriendsChatManager; -import net.runelite.api.FriendsChatRank; import net.runelite.api.Client; +import net.runelite.api.EnumComposition; +import net.runelite.api.EnumID; +import net.runelite.api.FriendsChatRank; import net.runelite.api.GameState; import net.runelite.api.IndexedSprite; -import net.runelite.api.SpriteID; -import net.runelite.api.events.FriendsChatChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.util.ImageUtil; -import net.runelite.client.util.Text; @Singleton -public class FriendChatManager +public class ChatIconManager { - private static final int[] RANK_IMAGES = - { - SpriteID.FRIENDS_CHAT_RANK_SMILEY_FRIEND, - SpriteID.FRIENDS_CHAT_RANK_SINGLE_CHEVRON_RECRUIT, - SpriteID.FRIENDS_CHAT_RANK_DOUBLE_CHEVRON_CORPORAL, - SpriteID.FRIENDS_CHAT_RANK_TRIPLE_CHEVRON_SERGEANT, - SpriteID.FRIENDS_CHAT_RANK_BRONZE_STAR_LIEUTENANT, - SpriteID.FRIENDS_CHAT_RANK_SILVER_STAR_CAPTAIN, - SpriteID.FRIENDS_CHAT_RANK_GOLD_STAR_GENERAL, - SpriteID.FRIENDS_CHAT_RANK_KEY_CHANNEL_OWNER, - SpriteID.FRIENDS_CHAT_RANK_CROWN_JAGEX_MODERATOR, - }; private static final Dimension IMAGE_DIMENSION = new Dimension(11, 11); private static final Color IMAGE_OUTLINE_COLOR = new Color(33, 33, 33); private final Client client; private final SpriteManager spriteManager; - private final BufferedImage[] rankImages = new BufferedImage[RANK_IMAGES.length]; - private final LoadingCache ranksCache = CacheBuilder.newBuilder() - .maximumSize(100) - .expireAfterWrite(1, TimeUnit.MINUTES) - .build(new CacheLoader() - { - @Override - public FriendsChatRank load(@Nonnull String key) - { - final FriendsChatManager friendsChatManager = client.getFriendsChatManager(); - if (friendsChatManager == null) - { - return FriendsChatRank.UNRANKED; - } + private BufferedImage[] friendsChatRankImages; - FriendsChatMember friendsChatMember = friendsChatManager.findByName(sanitize(key)); - return friendsChatMember != null ? friendsChatMember.getRank() : FriendsChatRank.UNRANKED; - } - }); - - private int offset; + private int friendsChatOffset; @Inject - private FriendChatManager(Client client, SpriteManager spriteManager, EventBus eventBus) + private ChatIconManager(Client client, SpriteManager spriteManager, EventBus eventBus) { this.client = client; this.spriteManager = spriteManager; eventBus.register(this); } - public boolean isMember(String name) - { - FriendsChatManager friendsChatManager = client.getFriendsChatManager(); - return friendsChatManager != null && friendsChatManager.findByName(name) != null; - } - - public FriendsChatRank getRank(String playerName) - { - return ranksCache.getUnchecked(playerName); - } - @Nullable public BufferedImage getRankImage(final FriendsChatRank friendsChatRank) { @@ -120,64 +71,57 @@ public class FriendChatManager return null; } - return rankImages[friendsChatRank.ordinal() - 1]; + return friendsChatRankImages[friendsChatRank.ordinal() - 1]; } public int getIconNumber(final FriendsChatRank friendsChatRank) { - return offset + friendsChatRank.ordinal() - 1; + return friendsChatOffset + friendsChatRank.ordinal() - 1; } @Subscribe public void onGameStateChanged(GameStateChanged gameStateChanged) { - if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN && offset == 0) + if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN && friendsChatOffset == 0) { loadRankIcons(); } } - @Subscribe - public void onFriendsChatChanged(FriendsChatChanged friendsChatChanged) - { - ranksCache.invalidateAll(); - } - private void loadRankIcons() { + final EnumComposition friendsChatIcons = client.getEnum(EnumID.FRIENDS_CHAT_RANK_ICONS); + { IndexedSprite[] modIcons = client.getModIcons(); - offset = modIcons.length; + friendsChatOffset = modIcons.length; IndexedSprite blank = ImageUtil.getImageIndexedSprite( new BufferedImage(modIcons[0].getWidth(), modIcons[0].getHeight(), BufferedImage.TYPE_INT_ARGB), client); - modIcons = Arrays.copyOf(modIcons, offset + RANK_IMAGES.length); - Arrays.fill(modIcons, offset, modIcons.length, blank); + modIcons = Arrays.copyOf(modIcons, friendsChatOffset + friendsChatIcons.size()); + Arrays.fill(modIcons, friendsChatOffset, modIcons.length, blank); client.setModIcons(modIcons); } - for (int i = 0; i < RANK_IMAGES.length; i++) + friendsChatRankImages = new BufferedImage[friendsChatIcons.size()]; + + final IndexedSprite[] modIcons = client.getModIcons(); + + for (int i = 0; i < friendsChatIcons.size(); i++) { final int fi = i; - spriteManager.getSpriteAsync(RANK_IMAGES[i], 0, sprite -> + spriteManager.getSpriteAsync(friendsChatIcons.getIntValue(friendsChatIcons.getKeys()[i]), 0, sprite -> { - IndexedSprite[] modIcons = client.getModIcons(); - rankImages[fi] = friendsChatImageFromSprite(sprite); - modIcons[offset + fi] = ImageUtil.getImageIndexedSprite(rankImages[fi], client); + friendsChatRankImages[fi] = friendsChatImageFromSprite(sprite); + modIcons[friendsChatOffset + fi] = ImageUtil.getImageIndexedSprite(friendsChatRankImages[fi], client); }); } } - private static String sanitize(String lookup) - { - final String cleaned = Text.removeTags(lookup); - return cleaned.replace('\u00A0', ' '); - } - private static BufferedImage friendsChatImageFromSprite(final BufferedImage sprite) { final BufferedImage canvas = ImageUtil.resizeCanvas(sprite, IMAGE_DIMENSION.width, IMAGE_DIMENSION.height); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java index 5340be1df0..c7252a46b3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java @@ -50,6 +50,7 @@ import static net.runelite.api.ChatMessageType.OBJECT_EXAMINE; import static net.runelite.api.ChatMessageType.PUBLICCHAT; import static net.runelite.api.ChatMessageType.SPAM; import net.runelite.api.Client; +import net.runelite.api.FriendsChatManager; import net.runelite.api.MessageNode; import net.runelite.api.Player; import net.runelite.api.events.ChatMessage; @@ -58,7 +59,6 @@ import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; -import net.runelite.client.game.FriendChatManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.util.Text; @@ -117,9 +117,6 @@ public class ChatFilterPlugin extends Plugin @Inject private ChatFilterConfig config; - @Inject - private FriendChatManager friendChatManager; - @Provides ChatFilterConfig provideConfig(ConfigManager configManager) { @@ -274,7 +271,13 @@ public class ChatFilterPlugin extends Plugin boolean isMessageFromSelf = playerName.equals(client.getLocalPlayer().getName()); return !isMessageFromSelf && (config.filterFriends() || !client.isFriended(playerName, false)) && - (config.filterFriendsChat() || !friendChatManager.isMember(playerName)); + (config.filterFriendsChat() || !isFriendsChatMember(playerName)); + } + + private boolean isFriendsChatMember(String name) + { + FriendsChatManager friendsChatManager = client.getFriendsChatManager(); + return friendsChatManager != null && friendsChatManager.findByName(name) != null; } String censorMessage(final String username, final String message) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/friendschat/FriendsChatPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/friendschat/FriendsChatPlugin.java index 2f6eb086a3..c7dc727b33 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/friendschat/FriendsChatPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/friendschat/FriendsChatPlugin.java @@ -76,7 +76,7 @@ import net.runelite.client.config.ChatColorConfig; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; -import net.runelite.client.game.FriendChatManager; +import net.runelite.client.game.ChatIconManager; import net.runelite.client.game.SpriteManager; import net.runelite.client.game.chatbox.ChatboxPanelManager; import net.runelite.client.plugins.Plugin; @@ -103,7 +103,7 @@ public class FriendsChatPlugin extends Plugin private Client client; @Inject - private FriendChatManager friendChatManager; + private ChatIconManager chatIconManager; @Inject private FriendsChatConfig config; @@ -398,7 +398,7 @@ public class FriendsChatPlugin extends Plugin if (config.chatIcons() && rank != null && rank != FriendsChatRank.UNRANKED) { - rankIcon = friendChatManager.getIconNumber(rank); + rankIcon = chatIconManager.getIconNumber(rank); } ChatMessageBuilder message = new ChatMessageBuilder() @@ -580,11 +580,11 @@ public class FriendsChatPlugin extends Plugin private void insertRankIcon(final ChatMessage message) { - final FriendsChatRank rank = friendChatManager.getRank(message.getName()); + final FriendsChatRank rank = getRank(message.getName()); if (rank != null && rank != FriendsChatRank.UNRANKED) { - int iconNumber = friendChatManager.getIconNumber(rank); + int iconNumber = chatIconManager.getIconNumber(rank); final String img = ""; if (message.getType() == ChatMessageType.FRIENDSCHAT) { @@ -600,6 +600,18 @@ public class FriendsChatPlugin extends Plugin } } + private FriendsChatRank getRank(String playerName) + { + final FriendsChatManager friendsChatManager = client.getFriendsChatManager(); + if (friendsChatManager == null) + { + return FriendsChatRank.UNRANKED; + } + + FriendsChatMember friendsChatMember = friendsChatManager.findByName(playerName); + return friendsChatMember != null ? friendsChatMember.getRank() : FriendsChatRank.UNRANKED; + } + private void rebuildFriendsChat() { Widget chat = client.getWidget(WidgetInfo.FRIENDS_CHAT_ROOT); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 5ca263a64c..063a3cd488 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -34,7 +34,7 @@ import javax.inject.Singleton; import net.runelite.api.FriendsChatRank; import net.runelite.api.Player; import net.runelite.api.Point; -import net.runelite.client.game.FriendChatManager; +import net.runelite.client.game.ChatIconManager; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; @@ -49,15 +49,15 @@ public class PlayerIndicatorsOverlay extends Overlay private final PlayerIndicatorsService playerIndicatorsService; private final PlayerIndicatorsConfig config; - private final FriendChatManager friendChatManager; + private final ChatIconManager chatIconManager; @Inject private PlayerIndicatorsOverlay(PlayerIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService, - FriendChatManager friendChatManager) + ChatIconManager chatIconManager) { this.config = config; this.playerIndicatorsService = playerIndicatorsService; - this.friendChatManager = friendChatManager; + this.chatIconManager = chatIconManager; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.MED); } @@ -108,13 +108,13 @@ public class PlayerIndicatorsOverlay extends Overlay return; } - if (config.showFriendsChatRanks() && actor.isFriendsChatMember()) + if (actor.isFriendsChatMember() && config.showFriendsChatRanks()) { - final FriendsChatRank rank = friendChatManager.getRank(name); + final FriendsChatRank rank = playerIndicatorsService.getFriendsChatRank(actor); if (rank != FriendsChatRank.UNRANKED) { - final BufferedImage rankImage = friendChatManager.getRankImage(rank); + final BufferedImage rankImage = chatIconManager.getRankImage(rank); if (rankImage != null) { @@ -145,4 +145,4 @@ public class PlayerIndicatorsOverlay extends Overlay OverlayUtil.renderTextLocation(graphics, textLocation, name, color); } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java index ef3863225d..b7c5d28471 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java @@ -28,16 +28,28 @@ import com.google.inject.Provides; import java.awt.Color; import javax.inject.Inject; import lombok.Value; +import net.runelite.api.Client; import net.runelite.api.FriendsChatRank; import static net.runelite.api.FriendsChatRank.UNRANKED; -import net.runelite.api.Client; -import static net.runelite.api.MenuAction.*; +import static net.runelite.api.MenuAction.ITEM_USE_ON_PLAYER; +import static net.runelite.api.MenuAction.MENU_ACTION_DEPRIORITIZE_OFFSET; +import static net.runelite.api.MenuAction.PLAYER_EIGTH_OPTION; +import static net.runelite.api.MenuAction.PLAYER_FIFTH_OPTION; +import static net.runelite.api.MenuAction.PLAYER_FIRST_OPTION; +import static net.runelite.api.MenuAction.PLAYER_FOURTH_OPTION; +import static net.runelite.api.MenuAction.PLAYER_SECOND_OPTION; +import static net.runelite.api.MenuAction.PLAYER_SEVENTH_OPTION; +import static net.runelite.api.MenuAction.PLAYER_SIXTH_OPTION; +import static net.runelite.api.MenuAction.PLAYER_THIRD_OPTION; +import static net.runelite.api.MenuAction.RUNELITE_PLAYER; +import static net.runelite.api.MenuAction.SPELL_CAST_ON_PLAYER; +import static net.runelite.api.MenuAction.WALK; import net.runelite.api.MenuEntry; import net.runelite.api.Player; import net.runelite.api.events.ClientTick; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.game.FriendChatManager; +import net.runelite.client.game.ChatIconManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; @@ -65,11 +77,14 @@ public class PlayerIndicatorsPlugin extends Plugin @Inject private PlayerIndicatorsMinimapOverlay playerIndicatorsMinimapOverlay; + @Inject + private PlayerIndicatorsService playerIndicatorsService; + @Inject private Client client; @Inject - private FriendChatManager friendChatManager; + private ChatIconManager chatIconManager; @Provides PlayerIndicatorsConfig provideConfig(ConfigManager configManager) @@ -182,10 +197,13 @@ public class PlayerIndicatorsPlugin extends Plugin { color = config.getFriendsChatMemberColor(); - FriendsChatRank rank = friendChatManager.getRank(player.getName()); - if (rank != UNRANKED) + if (config.showFriendsChatRanks()) { - image = friendChatManager.getIconNumber(rank); + FriendsChatRank rank = playerIndicatorsService.getFriendsChatRank(player); + if (rank != UNRANKED) + { + image = chatIconManager.getIconNumber(rank); + } } } else if (config.highlightTeamMembers() @@ -222,7 +240,7 @@ public class PlayerIndicatorsPlugin extends Plugin newTarget = ColorUtil.prependColorTag(newTarget, decorations.getColor()); } - if (decorations.getImage() != -1 && config.showFriendsChatRanks()) + if (decorations.getImage() != -1) { newTarget = "" + newTarget; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java index 8c9823f5c3..c0af49d7cb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java @@ -29,6 +29,9 @@ import java.util.function.BiConsumer; import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.Client; +import net.runelite.api.FriendsChatManager; +import net.runelite.api.FriendsChatMember; +import net.runelite.api.FriendsChatRank; import net.runelite.api.Player; @Singleton @@ -88,4 +91,16 @@ public class PlayerIndicatorsService } } } + + FriendsChatRank getFriendsChatRank(Player player) + { + final FriendsChatManager friendsChatManager = client.getFriendsChatManager(); + if (friendsChatManager == null) + { + return FriendsChatRank.UNRANKED; + } + + FriendsChatMember friendsChatMember = friendsChatManager.findByName(player.getName()); + return friendsChatMember != null ? friendsChatMember.getRank() : FriendsChatRank.UNRANKED; + } } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatfilter/ChatFilterPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatfilter/ChatFilterPluginTest.java index f12ae93e4a..501787576a 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatfilter/ChatFilterPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatfilter/ChatFilterPluginTest.java @@ -31,12 +31,13 @@ import com.google.inject.testing.fieldbinder.BoundFieldModule; import javax.inject.Inject; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; +import net.runelite.api.FriendsChatManager; +import net.runelite.api.FriendsChatMember; import net.runelite.api.IterableHashTable; import net.runelite.api.MessageNode; import net.runelite.api.Player; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ScriptCallbackEvent; -import net.runelite.client.game.FriendChatManager; import static net.runelite.client.plugins.chatfilter.ChatFilterPlugin.CENSOR_MESSAGE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -59,12 +60,11 @@ public class ChatFilterPluginTest private Client client; @Mock - @Bind - private ChatFilterConfig chatFilterConfig; + private FriendsChatManager friendsChatManager; @Mock @Bind - private FriendChatManager friendChatManager; + private ChatFilterConfig chatFilterConfig; @Mock private Player localPlayer; @@ -81,7 +81,9 @@ public class ChatFilterPluginTest when(chatFilterConfig.filteredWords()).thenReturn(""); when(chatFilterConfig.filteredRegex()).thenReturn(""); when(chatFilterConfig.filteredNames()).thenReturn(""); + when(client.getLocalPlayer()).thenReturn(localPlayer); + when(client.getFriendsChatManager()).thenReturn(friendsChatManager); } private ScriptCallbackEvent createCallbackEvent(final String sender, final String chatMessage, final ChatMessageType messageType) @@ -187,7 +189,6 @@ public class ChatFilterPluginTest @Test public void testMessageFromFriendIsFiltered() { - when(friendChatManager.isMember("Iron Mammal")).thenReturn(false); when(chatFilterConfig.filterFriends()).thenReturn(true); assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("Iron Mammal")); } @@ -211,7 +212,7 @@ public class ChatFilterPluginTest @Test public void testMessageFromFriendsChatIsNotFiltered() { - when(friendChatManager.isMember("B0aty")).thenReturn(true); + when(friendsChatManager.findByName("B0aty")).thenReturn(mock(FriendsChatMember.class)); when(chatFilterConfig.filterFriendsChat()).thenReturn(false); assertFalse(chatFilterPlugin.shouldFilterPlayerMessage("B0aty")); } @@ -227,7 +228,6 @@ public class ChatFilterPluginTest public void testMessageFromNonFriendNonFCIsFiltered() { when(client.isFriended("Woox", false)).thenReturn(false); - when(friendChatManager.isMember("Woox")).thenReturn(false); assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("Woox")); } @@ -414,7 +414,7 @@ public class ChatFilterPluginTest when(chatFilterConfig.filteredWords()).thenReturn("test"); // if this test is broken, this stubbing is required to trip the assert lenient().when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.REMOVE_MESSAGE); - when(friendChatManager.isMember("Lazark")).thenReturn(true); + when(friendsChatManager.findByName("Lazark")).thenReturn(mock(FriendsChatMember.class)); chatFilterPlugin.updateFilteredPatterns(); ScriptCallbackEvent event = createCallbackEvent("Lazark", "test", ChatMessageType.PUBLICCHAT); From 9794fc9597fb32298630ff959fcbbda24f8a904c Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 25 May 2021 14:13:17 -0400 Subject: [PATCH 10/15] Change config name of party plugin to disable by default Since the plugin was rewritten and changed to disable by default, it will not retroactively apply to existing configs without this --- .../client/plugins/PluginDescriptor.java | 5 +++++ .../client/plugins/PluginManager.java | 21 ++++++++----------- .../client/plugins/party/PartyPlugin.java | 1 + 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginDescriptor.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginDescriptor.java index 57a7a4718f..0a3336d203 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginDescriptor.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginDescriptor.java @@ -37,6 +37,11 @@ public @interface PluginDescriptor { String name(); + /** + * Internal name used in the config. + */ + String configName() default ""; + /** * A short, one-line summary of the plugin. */ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index 5b77ac6c12..1549e5cb74 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.google.common.graph.Graph; import com.google.common.graph.GraphBuilder; @@ -312,7 +313,8 @@ public class PluginManager { log.debug("Disabling {} due to safe mode", clazz); // also disable the plugin from autostarting later - configManager.unsetConfiguration(RuneLiteConfig.GROUP_NAME, clazz.getSimpleName().toLowerCase()); + configManager.unsetConfiguration(RuneLiteConfig.GROUP_NAME, + (Strings.isNullOrEmpty(pluginDescriptor.configName()) ? clazz.getSimpleName() : pluginDescriptor.configName()).toLowerCase()); continue; } @@ -440,22 +442,17 @@ public class PluginManager public void setPluginEnabled(Plugin plugin, boolean enabled) { - final String keyName = plugin.getClass().getSimpleName().toLowerCase(); - configManager.setConfiguration(RuneLiteConfig.GROUP_NAME, keyName, String.valueOf(enabled)); + final PluginDescriptor pluginDescriptor = plugin.getClass().getAnnotation(PluginDescriptor.class); + final String keyName = Strings.isNullOrEmpty(pluginDescriptor.configName()) ? plugin.getClass().getSimpleName() : pluginDescriptor.configName(); + configManager.setConfiguration(RuneLiteConfig.GROUP_NAME, keyName.toLowerCase(), String.valueOf(enabled)); } public boolean isPluginEnabled(Plugin plugin) { - final String keyName = plugin.getClass().getSimpleName().toLowerCase(); - final String value = configManager.getConfiguration(RuneLiteConfig.GROUP_NAME, keyName); - - if (value != null) - { - return Boolean.valueOf(value); - } - final PluginDescriptor pluginDescriptor = plugin.getClass().getAnnotation(PluginDescriptor.class); - return pluginDescriptor == null || pluginDescriptor.enabledByDefault(); + final String keyName = Strings.isNullOrEmpty(pluginDescriptor.configName()) ? plugin.getClass().getSimpleName() : pluginDescriptor.configName(); + final String value = configManager.getConfiguration(RuneLiteConfig.GROUP_NAME, keyName.toLowerCase()); + return value != null ? Boolean.parseBoolean(value) : pluginDescriptor.enabledByDefault(); } private Plugin instantiate(List scannedPlugins, Class clazz) throws PluginInstantiationException diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java index 789c0740e1..e9287210a8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java @@ -96,6 +96,7 @@ import net.runelite.http.api.ws.messages.party.UserSync; @PluginDescriptor( name = "Party", + configName = "PartyPlugin2", description = "Party management and basic info", enabledByDefault = false ) From a8603063bd7da6562853e4b0fb6c30dc334d2dbb Mon Sep 17 00:00:00 2001 From: RuneLite Cache-Code Autoupdater Date: Wed, 26 May 2021 10:53:10 +0000 Subject: [PATCH 11/15] Update Object IDs to 2021-05-26-rev196 --- runelite-api/src/main/java/net/runelite/api/NullObjectID.java | 2 -- runelite-api/src/main/java/net/runelite/api/ObjectID.java | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/NullObjectID.java b/runelite-api/src/main/java/net/runelite/api/NullObjectID.java index c321869be7..60d1378467 100644 --- a/runelite-api/src/main/java/net/runelite/api/NullObjectID.java +++ b/runelite-api/src/main/java/net/runelite/api/NullObjectID.java @@ -20303,8 +20303,6 @@ public final class NullObjectID public static final int NULL_41599 = 41599; public static final int NULL_41608 = 41608; public static final int NULL_41609 = 41609; - public static final int NULL_41610 = 41610; - public static final int NULL_41611 = 41611; public static final int NULL_41612 = 41612; public static final int NULL_41614 = 41614; public static final int NULL_41616 = 41616; diff --git a/runelite-api/src/main/java/net/runelite/api/ObjectID.java b/runelite-api/src/main/java/net/runelite/api/ObjectID.java index 328cfcedfa..0f0ab95c07 100644 --- a/runelite-api/src/main/java/net/runelite/api/ObjectID.java +++ b/runelite-api/src/main/java/net/runelite/api/ObjectID.java @@ -21293,6 +21293,8 @@ public final class ObjectID public static final int BOXES_41605 = 41605; public static final int SIGNPOST_41606 = 41606; public static final int TABLE_41607 = 41607; + public static final int BUSH_41610 = 41610; + public static final int BUSH_41611 = 41611; public static final int RED_BARRIER_41613 = 41613; public static final int POSTER_41615 = 41615; public static final int PORTAL_41617 = 41617; From a954cb81a9859bf0f8aff510275cabf8537099d9 Mon Sep 17 00:00:00 2001 From: RuneLite Cache-Code Autoupdater Date: Wed, 26 May 2021 10:53:10 +0000 Subject: [PATCH 12/15] Update NPC IDs to 2021-05-26-rev196 --- runelite-api/src/main/java/net/runelite/api/NpcID.java | 1 + 1 file changed, 1 insertion(+) diff --git a/runelite-api/src/main/java/net/runelite/api/NpcID.java b/runelite-api/src/main/java/net/runelite/api/NpcID.java index d323c2c3d5..044ecfcd5e 100644 --- a/runelite-api/src/main/java/net/runelite/api/NpcID.java +++ b/runelite-api/src/main/java/net/runelite/api/NpcID.java @@ -9094,5 +9094,6 @@ public final class NpcID public static final int GARDENER_JAY_JR_10757 = 10757; public static final int GARDENER_JAY_JR_10758 = 10758; public static final int CLERK_10759 = 10759; + public static final int STRAY_DOG_10760 = 10760; /* This file is automatically generated. Do not edit. */ } From 62f1ba6f6e3b2f1828fef816d4d234ad2c11cecb Mon Sep 17 00:00:00 2001 From: RuneLite Cache-Code Autoupdater Date: Wed, 26 May 2021 10:53:13 +0000 Subject: [PATCH 13/15] Update Scripts to 2021-05-26-rev196 --- .../src/main/scripts/PrivateMessage.hash | 2 +- .../src/main/scripts/PrivateMessage.rs2asm | 120 ++++++++++-------- 2 files changed, 66 insertions(+), 56 deletions(-) diff --git a/runelite-client/src/main/scripts/PrivateMessage.hash b/runelite-client/src/main/scripts/PrivateMessage.hash index 40e5d70cc6..c9c8d6ff7f 100644 --- a/runelite-client/src/main/scripts/PrivateMessage.hash +++ b/runelite-client/src/main/scripts/PrivateMessage.hash @@ -1 +1 @@ -559DA005256EF939AA48F2B0B2B8C5D05168D50D378253DF81B0B68C20331A95 \ No newline at end of file +D6803CE58C6976B2799C6410F4F3E806D1EFD5A8263DCAE9C5BF54A4426BFFD1 \ No newline at end of file diff --git a/runelite-client/src/main/scripts/PrivateMessage.rs2asm b/runelite-client/src/main/scripts/PrivateMessage.rs2asm index ee8c024fa3..a6ef72d6f4 100644 --- a/runelite-client/src/main/scripts/PrivateMessage.rs2asm +++ b/runelite-client/src/main/scripts/PrivateMessage.rs2asm @@ -25,7 +25,7 @@ LABEL10: iload 1 iconst 0 if_icmpgt LABEL21 - jump LABEL255 + jump LABEL265 LABEL21: get_varc_int 5 switch @@ -38,20 +38,20 @@ LABEL21: 7: LABEL110 8: LABEL116 9: LABEL124 - 10: LABEL191 - 11: LABEL247 - 12: LABEL207 - 13: LABEL225 + 10: LABEL201 + 11: LABEL257 + 12: LABEL217 + 13: LABEL235 15: LABEL124 - 16: LABEL252 - 18: LABEL247 + 16: LABEL262 + 18: LABEL257 19: LABEL110 20: LABEL124 21: LABEL124 - jump LABEL254 + jump LABEL264 LABEL24: return - jump LABEL254 + jump LABEL264 LABEL26: ignore_count iconst 0 @@ -79,7 +79,7 @@ LABEL44: get_varc_string 359 ignore_del LABEL46: - jump LABEL254 + jump LABEL264 LABEL47: friend_count iconst 0 @@ -163,14 +163,14 @@ LABEL107: clientclock set_varc_int 61 LABEL109: - jump LABEL254 + jump LABEL264 LABEL110: get_varc_string 359 invoke 212 resume_countdialog iconst 0 set_varc_int 5 - jump LABEL254 + jump LABEL264 LABEL116: get_varc_string 359 removetags @@ -179,7 +179,7 @@ LABEL116: resume_namedialog iconst 0 set_varc_int 5 - jump LABEL254 + jump LABEL264 LABEL124: get_varc_int 5 iconst 20 @@ -189,12 +189,12 @@ LABEL128: get_varc_string 359 removetags invoke 4394 - jump LABEL186 + jump LABEL196 LABEL132: get_varc_int 5 iconst 21 if_icmpeq LABEL136 - jump LABEL186 + jump LABEL196 LABEL136: get_varc_string 359 sconst "jagex" @@ -232,6 +232,16 @@ LABEL136: invoke 4191 set_varc_string 359 get_varc_string 359 + sconst "mod " + sconst " " + invoke 4191 + set_varc_string 359 + get_varc_string 359 + sconst "m0d " + sconst " " + invoke 4191 + set_varc_string 359 + get_varc_string 359 sconst "-" sconst " " invoke 4191 @@ -246,66 +256,66 @@ LABEL136: sconst " " invoke 4191 set_varc_string 359 -LABEL186: +LABEL196: get_varc_string 359 resume_stringdialog iconst 0 set_varc_int 5 - jump LABEL254 -LABEL191: + jump LABEL264 +LABEL201: get_varbit 8119 iconst 0 - if_icmpeq LABEL195 - jump LABEL201 -LABEL195: + if_icmpeq LABEL205 + jump LABEL211 +LABEL205: iconst 1 iconst 1 invoke 299 sconst "You must set a name before you can chat." mes return -LABEL201: +LABEL211: get_varc_string 359 removetags set_varc_string 362 get_varc_string 359 clan_joinchat - jump LABEL254 -LABEL207: + jump LABEL264 +LABEL217: iload 1 iconst 10 - if_icmpgt LABEL211 - jump LABEL217 -LABEL211: + if_icmpgt LABEL221 + jump LABEL227 +LABEL221: get_varc_string 359 iconst 0 iconst 9 substring sstore 0 - jump LABEL219 -LABEL217: + jump LABEL229 +LABEL227: get_varc_string 359 sstore 0 -LABEL219: +LABEL229: sload 0 lowercase chat_setmessagefilter invoke 553 invoke 84 - jump LABEL254 -LABEL225: + jump LABEL264 +LABEL235: get_varbit 8119 iconst 0 - if_icmpeq LABEL229 - jump LABEL235 -LABEL229: + if_icmpeq LABEL239 + jump LABEL245 +LABEL239: iconst 1 iconst 1 invoke 299 sconst "You must set a name before you can chat." mes return -LABEL235: +LABEL245: get_varc_string 359 iconst 0 set_varc_int 62 @@ -317,35 +327,35 @@ LABEL235: sconst "I1" iconst 10616843 if_setontimer - jump LABEL254 -LABEL247: + jump LABEL264 +LABEL257: iconst 0 iconst 1 invoke 299 return - jump LABEL254 -LABEL252: + jump LABEL264 +LABEL262: get_varc_string 359 invoke 2061 -LABEL254: - jump LABEL261 -LABEL255: +LABEL264: + jump LABEL271 +LABEL265: get_varc_int 5 switch - 16: LABEL260 - 20: LABEL258 - 21: LABEL258 - 7: LABEL258 - 8: LABEL258 - 9: LABEL258 - 15: LABEL258 - jump LABEL261 -LABEL258: + 16: LABEL270 + 20: LABEL268 + 21: LABEL268 + 7: LABEL268 + 8: LABEL268 + 9: LABEL268 + 15: LABEL268 + jump LABEL271 +LABEL268: return - jump LABEL261 -LABEL260: + jump LABEL271 +LABEL270: return -LABEL261: +LABEL271: iconst 1 iconst 1 invoke 299 From 4d5f84267c6b017f70c1b4a6595a3fede3e491e1 Mon Sep 17 00:00:00 2001 From: Runelite auto updater Date: Wed, 26 May 2021 11:16:32 +0000 Subject: [PATCH 14/15] Release 1.7.9 --- cache-client/pom.xml | 2 +- cache-updater/pom.xml | 2 +- cache/pom.xml | 2 +- http-api/pom.xml | 2 +- http-service/pom.xml | 2 +- pom.xml | 4 ++-- runelite-api/pom.xml | 2 +- runelite-client/pom.xml | 2 +- runelite-jshell/pom.xml | 2 +- runelite-script-assembler-plugin/pom.xml | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cache-client/pom.xml b/cache-client/pom.xml index 4af3fd9ba1..adbdb7e5c0 100644 --- a/cache-client/pom.xml +++ b/cache-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.9-SNAPSHOT + 1.7.9 cache-client diff --git a/cache-updater/pom.xml b/cache-updater/pom.xml index 58623dfb8d..2fa87b1279 100644 --- a/cache-updater/pom.xml +++ b/cache-updater/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.9-SNAPSHOT + 1.7.9 Cache Updater diff --git a/cache/pom.xml b/cache/pom.xml index c96021d85b..d38e8a56e4 100644 --- a/cache/pom.xml +++ b/cache/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.9-SNAPSHOT + 1.7.9 cache diff --git a/http-api/pom.xml b/http-api/pom.xml index 08141910b4..6b5e1f11cc 100644 --- a/http-api/pom.xml +++ b/http-api/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.9-SNAPSHOT + 1.7.9 Web API diff --git a/http-service/pom.xml b/http-service/pom.xml index 726215cd28..f5be82592d 100644 --- a/http-service/pom.xml +++ b/http-service/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.9-SNAPSHOT + 1.7.9 Web Service diff --git a/pom.xml b/pom.xml index b0a95fdd28..72bf11c739 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.9-SNAPSHOT + 1.7.9 pom RuneLite @@ -61,7 +61,7 @@ https://github.com/runelite/runelite scm:git:git://github.com/runelite/runelite scm:git:git@github.com:runelite/runelite - HEAD + runelite-parent-1.7.9 diff --git a/runelite-api/pom.xml b/runelite-api/pom.xml index dcaf4a73d0..d2005c42be 100644 --- a/runelite-api/pom.xml +++ b/runelite-api/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.9-SNAPSHOT + 1.7.9 runelite-api diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index 585af5a554..20ee38d4b6 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.9-SNAPSHOT + 1.7.9 client diff --git a/runelite-jshell/pom.xml b/runelite-jshell/pom.xml index 592232a900..45b6214e4b 100644 --- a/runelite-jshell/pom.xml +++ b/runelite-jshell/pom.xml @@ -30,7 +30,7 @@ net.runelite runelite-parent - 1.7.9-SNAPSHOT + 1.7.9 jshell diff --git a/runelite-script-assembler-plugin/pom.xml b/runelite-script-assembler-plugin/pom.xml index 098fa98120..95fe004919 100644 --- a/runelite-script-assembler-plugin/pom.xml +++ b/runelite-script-assembler-plugin/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.9-SNAPSHOT + 1.7.9 script-assembler-plugin From 771a484a18341049eb4bff7d5758bd324a784658 Mon Sep 17 00:00:00 2001 From: Runelite auto updater Date: Wed, 26 May 2021 11:16:39 +0000 Subject: [PATCH 15/15] Bump for 1.7.10-SNAPSHOT --- cache-client/pom.xml | 2 +- cache-updater/pom.xml | 2 +- cache/pom.xml | 2 +- http-api/pom.xml | 2 +- http-service/pom.xml | 2 +- pom.xml | 4 ++-- runelite-api/pom.xml | 2 +- runelite-client/pom.xml | 2 +- runelite-jshell/pom.xml | 2 +- runelite-script-assembler-plugin/pom.xml | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cache-client/pom.xml b/cache-client/pom.xml index adbdb7e5c0..ba47aca07f 100644 --- a/cache-client/pom.xml +++ b/cache-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.9 + 1.7.10-SNAPSHOT cache-client diff --git a/cache-updater/pom.xml b/cache-updater/pom.xml index 2fa87b1279..41dd73f90b 100644 --- a/cache-updater/pom.xml +++ b/cache-updater/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.9 + 1.7.10-SNAPSHOT Cache Updater diff --git a/cache/pom.xml b/cache/pom.xml index d38e8a56e4..4cdb0ae997 100644 --- a/cache/pom.xml +++ b/cache/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.9 + 1.7.10-SNAPSHOT cache diff --git a/http-api/pom.xml b/http-api/pom.xml index 6b5e1f11cc..29c668e5ec 100644 --- a/http-api/pom.xml +++ b/http-api/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.9 + 1.7.10-SNAPSHOT Web API diff --git a/http-service/pom.xml b/http-service/pom.xml index f5be82592d..8e0d60797d 100644 --- a/http-service/pom.xml +++ b/http-service/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.9 + 1.7.10-SNAPSHOT Web Service diff --git a/pom.xml b/pom.xml index 72bf11c739..086443a859 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.9 + 1.7.10-SNAPSHOT pom RuneLite @@ -61,7 +61,7 @@ https://github.com/runelite/runelite scm:git:git://github.com/runelite/runelite scm:git:git@github.com:runelite/runelite - runelite-parent-1.7.9 + HEAD diff --git a/runelite-api/pom.xml b/runelite-api/pom.xml index d2005c42be..a6822da11e 100644 --- a/runelite-api/pom.xml +++ b/runelite-api/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.9 + 1.7.10-SNAPSHOT runelite-api diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index 20ee38d4b6..22ad275e52 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.9 + 1.7.10-SNAPSHOT client diff --git a/runelite-jshell/pom.xml b/runelite-jshell/pom.xml index 45b6214e4b..eaf8a233fc 100644 --- a/runelite-jshell/pom.xml +++ b/runelite-jshell/pom.xml @@ -30,7 +30,7 @@ net.runelite runelite-parent - 1.7.9 + 1.7.10-SNAPSHOT jshell diff --git a/runelite-script-assembler-plugin/pom.xml b/runelite-script-assembler-plugin/pom.xml index 95fe004919..7dc305d863 100644 --- a/runelite-script-assembler-plugin/pom.xml +++ b/runelite-script-assembler-plugin/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.9 + 1.7.10-SNAPSHOT script-assembler-plugin