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 d631395b89..e1bc085ab0 100644 --- a/runelite-api/src/main/java/net/runelite/api/ChatMessageType.java +++ b/runelite-api/src/main/java/net/runelite/api/ChatMessageType.java @@ -173,9 +173,9 @@ public enum ChatMessageType */ CLAN_CREATION_INVITATION(109), /** - * Clan wars challenge for clans rather than FCs + * Challenge offer for the clan tab */ - CLAN_CLAN_WARS_CHALLENGE(110), + CHALREQ_CLANCHAT(110), CLAN_GIM_FORM_GROUP(111), CLAN_GIM_GROUP_WITH(112), diff --git a/runelite-api/src/main/java/net/runelite/api/VarPlayer.java b/runelite-api/src/main/java/net/runelite/api/VarPlayer.java index d01cfc7350..b3520cf609 100644 --- a/runelite-api/src/main/java/net/runelite/api/VarPlayer.java +++ b/runelite-api/src/main/java/net/runelite/api/VarPlayer.java @@ -205,7 +205,38 @@ public enum VarPlayer /** * {@link NpcID} for the HP HUD */ - HP_HUD_NPC_ID(1683); + HP_HUD_NPC_ID(1683), + + /** + * Colors for chat messages + */ + SETTINGS_OPAQUE_CHAT_PUBLIC(2992), + SETTINGS_OPAQUE_CHAT_PRIVATE(2993), + SETTINGS_OPAQUE_CHAT_AUTO(2994), + SETTINGS_OPAQUE_CHAT_BROADCAST(2995), + SETTINGS_OPAQUE_CHAT_FRIEND(2996), + SETTINGS_OPAQUE_CHAT_CLAN(2997), + SETTINGS_OPAQUE_CHAT_GUEST_CLAN(3060), + SETTINGS_OPAQUE_CHAT_CLAN_BROADCAST(3192), + SETTINGS_OPAQUE_CHAT_IRON_GROUP_CHAT(3191), + SETTINGS_OPAQUE_CHAT_IRON_GROUP_BROADCAST(3193), + SETTINGS_OPAQUE_CHAT_TRADE_REQUEST(2998), + SETTINGS_OPAQUE_CHAT_CHALLENGE_REQUEST(2999), + + SETTINGS_TRANSPARENT_CHAT_PUBLIC(3000), + SETTINGS_TRANSPARENT_CHAT_PRIVATE(3001), + SETTINGS_TRANSPARENT_CHAT_AUTO(3002), + SETTINGS_TRANSPARENT_CHAT_BROADCAST(3003), + SETTINGS_TRANSPARENT_CHAT_FRIEND(3004), + SETTINGS_TRANSPARENT_CHAT_CLAN(3005), + SETTINGS_TRANSPARENT_CHAT_GUEST_CLAN(3061), + SETTINGS_TRANSPARENT_CHAT_CLAN_BROADCAST(3195), + SETTINGS_TRANSPARENT_CHAT_IRON_GROUP_CHAT(3194), + SETTINGS_TRANSPARENT_CHAT_IRON_GROUP_BROADCAST(3196), + SETTINGS_TRANSPARENT_CHAT_TRADE_REQUEST(3006), + SETTINGS_TRANSPARENT_CHAT_CHALLENGE_REQUEST(3007), + + ; private final int id; } \ No newline at end of file diff --git a/runelite-api/src/main/java/net/runelite/api/clan/ClanMember.java b/runelite-api/src/main/java/net/runelite/api/clan/ClanMember.java index 896939a505..dfe4151764 100644 --- a/runelite-api/src/main/java/net/runelite/api/clan/ClanMember.java +++ b/runelite-api/src/main/java/net/runelite/api/clan/ClanMember.java @@ -24,21 +24,18 @@ */ package net.runelite.api.clan; -import lombok.Value; - /** * A member of a clan. */ -@Value -public class ClanMember +public interface ClanMember { /** * The clan member's name */ - String name; + String getName(); /** * The clan member's rank */ - ClanRank rank; + ClanRank getRank(); } diff --git a/runelite-client/src/main/java/net/runelite/client/chat/ChatColor.java b/runelite-client/src/main/java/net/runelite/client/chat/ChatColor.java index 0a6dfdfaf2..6db6101328 100644 --- a/runelite-client/src/main/java/net/runelite/client/chat/ChatColor.java +++ b/runelite-client/src/main/java/net/runelite/client/chat/ChatColor.java @@ -25,28 +25,26 @@ package net.runelite.client.chat; import java.awt.Color; +import javax.annotation.Nullable; +import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; +import net.runelite.api.VarPlayer; @Data -@EqualsAndHashCode(exclude = {"color", "isDefault"}) -public class ChatColor +@EqualsAndHashCode(exclude = {"color", "isDefault", "setting"}) +@AllArgsConstructor +class ChatColor { private ChatColorType type; private Color color; private boolean transparent; private boolean isDefault; + @Nullable + private VarPlayer setting; // varp for the in-game chat color setting public ChatColor(ChatColorType type, Color color, boolean transparent) { - this(type, color, transparent, false); - } - - public ChatColor(ChatColorType type, Color color, boolean transparent, boolean isDefault) - { - this.type = type; - this.color = color; - this.transparent = transparent; - this.isDefault = isDefault; + this(type, color, transparent, false, null); } } diff --git a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java index 42bc06a17f..91d7c99683 100644 --- a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java +++ b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java @@ -31,23 +31,19 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; import java.awt.Color; -import java.util.Arrays; import java.util.Collection; -import java.util.Objects; import java.util.Queue; import java.util.Set; import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.MessageNode; import net.runelite.api.Player; +import net.runelite.api.VarPlayer; import net.runelite.api.Varbits; -import net.runelite.api.events.ResizeableChanged; import net.runelite.api.events.ScriptCallbackEvent; -import net.runelite.api.events.VarbitChanged; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ChatColorConfig; import net.runelite.client.eventbus.EventBus; @@ -66,7 +62,6 @@ public class ChatMessageManager private final Client client; private final ChatColorConfig chatColorConfig; private final ClientThread clientThread; - private int transparencyVarbit = -1; private final Queue queuedMessages = new ConcurrentLinkedQueue<>(); @Inject @@ -83,40 +78,25 @@ public class ChatMessageManager loadColors(); } - @Subscribe - public void onVarbitChanged(VarbitChanged event) - { - int setting = client.getVar(Varbits.TRANSPARENT_CHATBOX); - - if (transparencyVarbit != setting) - { - transparencyVarbit = setting; - refreshAll(); - } - } - - @Subscribe - public void onResizeableChanged(ResizeableChanged event) - { - refreshAll(); - } - @Subscribe public void onConfigChanged(ConfigChanged event) { if (event.getGroup().equals("textrecolor")) { loadColors(); - clientThread.invokeLater(this::refreshAll); + clientThread.invokeLater(client::refreshChat); } } @VisibleForTesting void colorChatMessage() { + final int[] intStack = client.getIntStack(); final String[] stringStack = client.getStringStack(); final int size = client.getStringStackSize(); - final int uid = client.getIntStack()[client.getIntStackSize() - 1]; + final int isize = client.getIntStackSize(); + final int uid = intStack[isize - 1]; + final boolean splitpmbox = intStack[isize - 2] == 1; final MessageNode messageNode = client.getMessages().get(uid); assert messageNode != null : "chat message build for unknown message"; @@ -184,6 +164,12 @@ public class ChatMessageManager stringStack[size - 4] = ColorUtil.wrapWithColorTag(channel, channelColor); } + if (messageNode.getRuneLiteFormatMessage() != null) + { + stringStack[size - 2] = message = formatRuneLiteMessage(messageNode.getRuneLiteFormatMessage(), + chatMessageType, splitpmbox); + } + final Collection chatColors = colorCache.get(chatMessageType); for (ChatColor chatColor : chatColors) { @@ -311,6 +297,86 @@ public class ChatMessageManager return null; } + // get the variable holding the chat color from the settings, from script4484 + private static VarPlayer getSettingsColor(ChatMessageType type, boolean transparent) + { + if (transparent) + { + switch (type) + { + case PUBLICCHAT: + case MODCHAT: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_PUBLIC; + case PRIVATECHATOUT: + case MODPRIVATECHAT: + case PRIVATECHAT: + case LOGINLOGOUTNOTIFICATION: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_PRIVATE; + case AUTOTYPER: + case MODAUTOTYPER: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_AUTO; + case BROADCAST: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_BROADCAST; + case FRIENDSCHAT: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_FRIEND; + case CLAN_CHAT: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_CLAN; + case TRADEREQ: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_TRADE_REQUEST; + case CHALREQ_TRADE: + case CHALREQ_FRIENDSCHAT: + case CHALREQ_CLANCHAT: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_CHALLENGE_REQUEST; + case CLAN_GUEST_CHAT: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_GUEST_CLAN; + case CLAN_GIM_CHAT: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_IRON_GROUP_CHAT; + case CLAN_MESSAGE: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_CLAN_BROADCAST; + case CLAN_GIM_MESSAGE: + return VarPlayer.SETTINGS_TRANSPARENT_CHAT_IRON_GROUP_BROADCAST; + } + } + else + { + switch (type) + { + case PUBLICCHAT: + case MODCHAT: + return VarPlayer.SETTINGS_OPAQUE_CHAT_PUBLIC; + case PRIVATECHATOUT: + case MODPRIVATECHAT: + case PRIVATECHAT: + case LOGINLOGOUTNOTIFICATION: + return VarPlayer.SETTINGS_OPAQUE_CHAT_PRIVATE; + case AUTOTYPER: + case MODAUTOTYPER: + return VarPlayer.SETTINGS_OPAQUE_CHAT_AUTO; + case BROADCAST: + return VarPlayer.SETTINGS_OPAQUE_CHAT_BROADCAST; + case FRIENDSCHAT: + return VarPlayer.SETTINGS_OPAQUE_CHAT_FRIEND; + case CLAN_CHAT: + return VarPlayer.SETTINGS_OPAQUE_CHAT_CLAN; + case TRADEREQ: + return VarPlayer.SETTINGS_OPAQUE_CHAT_TRADE_REQUEST; + case CHALREQ_TRADE: + case CHALREQ_FRIENDSCHAT: + case CHALREQ_CLANCHAT: + return VarPlayer.SETTINGS_OPAQUE_CHAT_CHALLENGE_REQUEST; + case CLAN_GUEST_CHAT: + return VarPlayer.SETTINGS_OPAQUE_CHAT_GUEST_CLAN; + case CLAN_GIM_CHAT: + return VarPlayer.SETTINGS_OPAQUE_CHAT_IRON_GROUP_CHAT; + case CLAN_MESSAGE: + return VarPlayer.SETTINGS_OPAQUE_CHAT_CLAN_BROADCAST; + case CLAN_GIM_MESSAGE: + return VarPlayer.SETTINGS_OPAQUE_CHAT_IRON_GROUP_BROADCAST; + } + } + return null; + } + /** * Load all configured colors */ @@ -324,13 +390,13 @@ public class ChatMessageManager Color defaultTransparent = getDefaultColor(chatMessageType, true); if (defaultTransparent != null) { - cacheColor(new ChatColor(ChatColorType.NORMAL, defaultTransparent, true, true), chatMessageType); + cacheColor(new ChatColor(ChatColorType.NORMAL, defaultTransparent, true, true, getSettingsColor(chatMessageType, true)), chatMessageType); } Color defaultOpaque = getDefaultColor(chatMessageType, false); if (defaultOpaque != null) { - cacheColor(new ChatColor(ChatColorType.NORMAL, defaultOpaque, false, true), chatMessageType); + cacheColor(new ChatColor(ChatColorType.NORMAL, defaultOpaque, false, true, getSettingsColor(chatMessageType, false)), chatMessageType); } } @@ -744,13 +810,11 @@ public class ChatMessageManager return; } - final String formattedMessage = formatRuneLiteMessage(message.getRuneLiteFormattedMessage(), message.getType()); - // this updates chat cycle final MessageNode line = client.addChatMessage( message.getType(), MoreObjects.firstNonNull(message.getName(), ""), - MoreObjects.firstNonNull(formattedMessage, message.getValue()), + MoreObjects.firstNonNull(message.getRuneLiteFormattedMessage(), message.getValue()), message.getSender()); // Update the message with RuneLite additions @@ -763,55 +827,64 @@ public class ChatMessageManager } /** - * Rebuild the message node message from the RuneLite format message + * Rebuild the message node message from the RuneLite format message. + * DEPRECATED: no longer needs to be called. * * @param messageNode message node */ + @Deprecated public void update(final MessageNode messageNode) { - String message = formatRuneLiteMessage(messageNode.getRuneLiteFormatMessage(), messageNode.getType()); - if (message != null) - { - messageNode.setValue(message); - } } - private String formatRuneLiteMessage(String runeLiteFormatMessage, ChatMessageType type) + @VisibleForTesting + String formatRuneLiteMessage(String runeLiteFormatMessage, ChatMessageType type, boolean pmbox) { - if (Strings.isNullOrEmpty(runeLiteFormatMessage)) - { - return null; - } - - final boolean transparent = client.isResized() && transparencyVarbit != 0; + final boolean transparentChatbox = client.getVar(Varbits.TRANSPARENT_CHATBOX) != 0; + final boolean transparent = client.isResized() && transparentChatbox; final Collection chatColors = colorCache.get(type); - - if (chatColors == null || chatColors.isEmpty()) + for (ChatColor chatColor : chatColors) { - return runeLiteFormatMessage; + if (chatColor.isTransparent() == transparent) + { + String colstr; + + if (pmbox && chatColor.getType() == ChatColorType.NORMAL) + { + // The default ChatColors for private have the chatbox text color, not the split chat color, + // and the split chat color is set by widget color, so just use . The in-game + // private chat color doesn't apply to split chat either so using that here also is incorrect. + // + // If we recolor the final message later we replace with the desired color in + // colorChatMessage() + colstr = ColorUtil.CLOSING_COLOR_TAG; + } + else + { + Color color = chatColor.getColor(); + + VarPlayer varp = chatColor.getSetting(); + if (varp != null) + { + // Apply configured color from game settings, if set + assert chatColor.isDefault(); + int v = client.getVar(varp); + if (v != 0) + { + color = new Color(v - 1); + } + } + + colstr = ColorUtil.colorTag(color); + } + + // Replace custom formatting with actual colors + runeLiteFormatMessage = runeLiteFormatMessage.replaceAll( + "", + colstr); + } } - final AtomicReference resultMessage = new AtomicReference<>(runeLiteFormatMessage); - - // Replace custom formatting with actual colors - chatColors.stream() - .filter(chatColor -> chatColor.isTransparent() == transparent) - .forEach(chatColor -> - resultMessage.getAndUpdate(oldMessage -> oldMessage.replaceAll( - "", - ColorUtil.colorTag(chatColor.getColor())))); - - return resultMessage.get(); - } - - private void refreshAll() - { - client.getChatLineMap().values().stream() - .filter(Objects::nonNull) - .flatMap(clb -> Arrays.stream(clb.getLines())) - .filter(Objects::nonNull) - .forEach(this::update); - - client.refreshChat(); + return runeLiteFormatMessage; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index 61da99f6fd..f1e72c9303 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -77,7 +77,6 @@ import net.runelite.client.chat.ChatClient; import net.runelite.client.chat.ChatColorType; import net.runelite.client.chat.ChatCommandManager; import net.runelite.client.chat.ChatMessageBuilder; -import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.eventbus.Subscribe; @@ -175,9 +174,6 @@ public class ChatCommandsPlugin extends Plugin @Inject private ItemManager itemManager; - @Inject - private ChatMessageManager chatMessageManager; - @Inject private ChatCommandManager chatCommandManager; @@ -840,7 +836,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } @@ -930,7 +925,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } @@ -974,7 +968,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } @@ -1061,7 +1054,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } @@ -1137,7 +1129,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } @@ -1231,7 +1222,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } @@ -1321,7 +1311,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } } @@ -1403,7 +1392,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } catch (IOException ex) @@ -1488,7 +1476,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } catch (IOException ex) @@ -1616,7 +1603,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } catch (IOException ex) @@ -1710,7 +1696,6 @@ public class ChatCommandsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } catch (IOException ex) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java index 9f74205102..44a04477b3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java @@ -47,7 +47,6 @@ import net.runelite.api.events.ChatMessage; import net.runelite.api.events.GameStateChanged; import net.runelite.client.Notifier; import net.runelite.client.chat.ChatColorType; -import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; @@ -69,9 +68,6 @@ public class ChatNotificationsPlugin extends Plugin @Inject private ChatNotificationsConfig config; - @Inject - private ChatMessageManager chatMessageManager; - @Inject private Notifier notifier; @@ -243,12 +239,24 @@ public class ChatNotificationsPlugin extends Plugin Matcher matcher = usernameMatcher.matcher(message); if (matcher.find()) { - final int start = matcher.start(); final String username = client.getLocalPlayer().getName(); - final String closeColor = MoreObjects.firstNonNull(getLastColor(message.substring(0, start)), ""); - final String replacement = "" + username + "" + closeColor; - messageNode.setValue(matcher.replaceAll(replacement)); + StringBuffer stringBuffer = new StringBuffer(); + do + { + final int start = matcher.start(); // start not end, since username won't contain a col tag + final String closeColor = MoreObjects.firstNonNull( + getLastColor(message.substring(0, start)), + "'); + final String replacement = "" + username + "" + closeColor; + matcher.appendReplacement(stringBuffer, replacement); + } + while (matcher.find()); + + matcher.appendTail(stringBuffer); + + messageNode.setValue(stringBuffer.toString()); update = true; + if (config.notifyOnOwnName() && (chatMessage.getType() == ChatMessageType.PUBLICCHAT || chatMessage.getType() == ChatMessageType.PRIVATECHAT || chatMessage.getType() == ChatMessageType.FRIENDSCHAT @@ -279,26 +287,16 @@ public class ChatNotificationsPlugin extends Plugin do { - String value = matcher.group(); - - // Determine the ending color by: - // 1) use the color from value if it has one - // 2) use the last color from stringBuffer + - // To do #2 we just search for the last col tag after calling appendReplacement - String endColor = getLastColor(value); - + final int end = matcher.end(); + // Determine the ending color by finding the last color tag up to and + // including the match. + final String closeColor = MoreObjects.firstNonNull( + getLastColor(nodeValue.substring(0, end)), + "'); // Strip color tags from the highlighted region so that it remains highlighted correctly - value = stripColor(value); + final String value = stripColor(matcher.group()); - matcher.appendReplacement(stringBuffer, "' + value); - - if (endColor == null) - { - endColor = getLastColor(stringBuffer.toString()); - } - - // Append end color - stringBuffer.append(endColor == null ? "" : endColor); + matcher.appendReplacement(stringBuffer, "' + value + closeColor); update = true; matchesHighlight = true; @@ -322,7 +320,6 @@ public class ChatNotificationsPlugin extends Plugin if (update) { messageNode.setRuneLiteFormatMessage(messageNode.getValue()); - chatMessageManager.update(messageNode); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java index 01693334e1..2e32a8e336 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java @@ -131,6 +131,17 @@ public interface GroundItemsConfig extends Config { return false; } + + @ConfigItem( + keyName = "deprioritizeHiddenItems", + name = "Deprioritize Menu Hidden Items", + description = "Depriotizies the menu options for items which are hidden, requiring a right click to pick up.", + position = 5 + ) + default boolean deprioritizeHiddenItems() + { + return false; + } @ConfigItem( keyName = "highlightTiles", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index 25338d4285..773fd8b044 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -116,8 +116,6 @@ public class GroundItemsPlugin extends Plugin // ItemID for coins private static final int COINS = ItemID.COINS_995; - private static final String TELEGRAB_TEXT = ColorUtil.wrapWithColorTag("Telekinetic Grab", Color.GREEN) + ColorUtil.prependColorTag(" -> ", Color.WHITE); - @Getter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE) private Map.Entry textBoxBounds; @@ -481,14 +479,11 @@ public class GroundItemsPlugin extends Plugin @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if (config.itemHighlightMode() == ItemHighlightMode.MENU || config.itemHighlightMode() == ItemHighlightMode.BOTH) + MenuAction type = MenuAction.of(event.getType()); + if (type == MenuAction.GROUND_ITEM_FIRST_OPTION || type == MenuAction.GROUND_ITEM_SECOND_OPTION || + type == MenuAction.GROUND_ITEM_THIRD_OPTION || type == MenuAction.GROUND_ITEM_FOURTH_OPTION || + type == MenuAction.GROUND_ITEM_FIFTH_OPTION || type == MenuAction.SPELL_CAST_ON_GROUND_ITEM) { - final boolean telegrabEntry = event.getOption().equals("Cast") && event.getTarget().startsWith(TELEGRAB_TEXT) && event.getType() == MenuAction.SPELL_CAST_ON_GROUND_ITEM.getId(); - if (!(event.getOption().equals("Take") && event.getType() == MenuAction.GROUND_ITEM_THIRD_OPTION.getId()) && !telegrabEntry) - { - return; - } - final int itemId = event.getIdentifier(); final int sceneX = event.getActionParam0(); final int sceneY = event.getActionParam1(); @@ -507,33 +502,24 @@ public class GroundItemsPlugin extends Plugin final Color color = getItemColor(highlighted, hidden); final boolean canBeRecolored = highlighted != null || (hidden != null && config.recolorMenuHiddenItems()); - if (color != null && canBeRecolored && !color.equals(config.defaultColor())) + if ((config.itemHighlightMode() == ItemHighlightMode.MENU || config.itemHighlightMode() == ItemHighlightMode.BOTH) && + (color != null && canBeRecolored && !color.equals(config.defaultColor()))) { final MenuHighlightMode mode = config.menuHighlightMode(); if (mode == BOTH || mode == OPTION) { - final String optionText = telegrabEntry ? "Cast" : "Take"; - lastEntry.setOption(ColorUtil.prependColorTag(optionText, color)); + lastEntry.setOption(ColorUtil.prependColorTag(lastEntry.getOption(), color)); } if (mode == BOTH || mode == NAME) { + // Logs + // Telekinetic Grab -> Logs String target = lastEntry.getTarget(); - if (telegrabEntry) - { - target = target.substring(TELEGRAB_TEXT.length()); - } - - target = ColorUtil.prependColorTag(target.substring(target.indexOf('>') + 1), color); - - if (telegrabEntry) - { - target = TELEGRAB_TEXT + target; - } - - lastEntry.setTarget(target); + int i = target.lastIndexOf('>'); + lastEntry.setTarget(target.substring(0, i - 11) + ColorUtil.colorTag(color) + target.substring(i + 1)); } } @@ -541,6 +527,11 @@ public class GroundItemsPlugin extends Plugin { lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")"); } + + if (hidden != null && highlighted == null && config.deprioritizeHiddenItems()) + { + lastEntry.setDeprioritized(true); + } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index 4722d85d85..dd1b96bd3f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -830,7 +830,6 @@ public class RaidsPlugin extends Plugin log.debug("Setting response {}", response); final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java index 0a2333ae2e..f7913a57c5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java @@ -79,7 +79,6 @@ import net.runelite.client.chat.ChatClient; import net.runelite.client.chat.ChatColorType; import net.runelite.client.chat.ChatCommandManager; import net.runelite.client.chat.ChatMessageBuilder; -import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ChatInput; @@ -161,9 +160,6 @@ public class SlayerPlugin extends Plugin @Inject private TargetWeaknessOverlay targetWeaknessOverlay; - @Inject - private ChatMessageManager chatMessageManager; - @Inject private ChatCommandManager chatCommandManager; @@ -875,7 +871,6 @@ public class SlayerPlugin extends Plugin final MessageNode messageNode = chatMessage.getMessageNode(); messageNode.setRuneLiteFormatMessage(response); - chatMessageManager.update(messageNode); client.refreshChat(); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtPlugin.java index 63b7f61331..bc7d374c60 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtPlugin.java @@ -69,7 +69,6 @@ import net.runelite.api.events.GameTick; import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.VarbitChanged; import net.runelite.client.Notifier; -import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; @@ -105,9 +104,6 @@ public class WintertodtPlugin extends Plugin @Inject private WintertodtConfig config; - @Inject - private ChatMessageManager chatMessageManager; - @Getter(AccessLevel.PACKAGE) private WintertodtActivity currentActivity = WintertodtActivity.IDLE; @@ -314,7 +310,6 @@ public class WintertodtPlugin extends Plugin // Recolor message for damage notification messageNode.setRuneLiteFormatMessage(ColorUtil.wrapWithColorTag(messageNode.getValue(), config.damageNotificationColor())); - chatMessageManager.update(messageNode); client.refreshChat(); // all actions except woodcutting and idle are interrupted from damage diff --git a/runelite-client/src/main/java/net/runelite/client/ui/JagexColors.java b/runelite-client/src/main/java/net/runelite/client/ui/JagexColors.java index aaab638696..1f61f5346a 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/JagexColors.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/JagexColors.java @@ -35,7 +35,7 @@ public class JagexColors * Colors of chat text when displayed on an opaque background. */ public static final Color CHAT_PUBLIC_TEXT_OPAQUE_BACKGROUND = Color.BLUE; - public static final Color CHAT_PRIVATE_MESSAGE_TEXT_OPAQUE_BACKGROUND = Color.CYAN; + public static final Color CHAT_PRIVATE_MESSAGE_TEXT_OPAQUE_BACKGROUND = new Color(0x7F0000); // in chatbox, not split chat public static final Color CHAT_FC_TEXT_OPAQUE_BACKGROUND = new Color(127, 0, 0); public static final Color CHAT_FC_NAME_OPAQUE_BACKGROUND = Color.BLUE; public static final Color CHAT_GAME_EXAMINE_TEXT_OPAQUE_BACKGROUND = Color.BLACK; @@ -45,7 +45,7 @@ public class JagexColors * Colors of chat text when displayed on a transparent background. */ public static final Color CHAT_PUBLIC_TEXT_TRANSPARENT_BACKGROUND = new Color(144, 144, 255); - public static final Color CHAT_PRIVATE_MESSAGE_TEXT_TRANSPARENT_BACKGROUND = Color.CYAN; + public static final Color CHAT_PRIVATE_MESSAGE_TEXT_TRANSPARENT_BACKGROUND = new Color(0xBF2020); // in chatbox, not split chat public static final Color CHAT_FC_TEXT_TRANSPARENT_BACKGROUND = new Color(239, 80, 80); public static final Color CHAT_FC_NAME_TRANSPARENT_BACKGROUND = new Color(144, 112, 255); public static final Color CHAT_GAME_EXAMINE_TEXT_TRANSPARENT_BACKGROUND = Color.WHITE; diff --git a/runelite-client/src/main/scripts/ChatBuilder.rs2asm b/runelite-client/src/main/scripts/ChatBuilder.rs2asm index e3739e6da4..eeb6f602dd 100644 --- a/runelite-client/src/main/scripts/ChatBuilder.rs2asm +++ b/runelite-client/src/main/scripts/ChatBuilder.rs2asm @@ -440,14 +440,16 @@ LABEL391: if_icmpeq LABEL406 jump LABEL1751 LABEL406: + iconst 0 ; splitpmbox iload 10 ; message uid sload 17 ; message channel sload 16 ; message name sload 18 ; message sload 21 ; message timestamp sconst "chatMessageBuilding" - runelite_callback + runelite_callback pop_int ; pop uid + pop_int ; splitpmbox sstore 21 ; message timestamp sstore 18 ; message sstore 16 ; message name diff --git a/runelite-client/src/main/scripts/ChatSplitBuilder.rs2asm b/runelite-client/src/main/scripts/ChatSplitBuilder.rs2asm index eb8907443e..e68c16f9db 100644 --- a/runelite-client/src/main/scripts/ChatSplitBuilder.rs2asm +++ b/runelite-client/src/main/scripts/ChatSplitBuilder.rs2asm @@ -413,14 +413,16 @@ CHAT_FILTER: if_icmpeq LABEL369 ; Check if we are building this message jump LABEL555 LABEL369: + iconst 1 ; splitpmbox iload 12 ; message uid sconst "" ; message channel sload 1 ; message name sload 0 ; message sload 2 ; message timestamp sconst "chatMessageBuilding" - runelite_callback + runelite_callback pop_int ; uid + pop_int ; splitpmbox sstore 2 ; message timestamp sstore 0 ; message sstore 1 ; message name diff --git a/runelite-client/src/test/java/net/runelite/client/chat/ChatMessageManagerTest.java b/runelite-client/src/test/java/net/runelite/client/chat/ChatMessageManagerTest.java index f389702dce..5f5d2d59a9 100644 --- a/runelite-client/src/test/java/net/runelite/client/chat/ChatMessageManagerTest.java +++ b/runelite-client/src/test/java/net/runelite/client/chat/ChatMessageManagerTest.java @@ -43,7 +43,6 @@ import org.junit.runner.RunWith; import static org.mockito.ArgumentMatchers.anyLong; import org.mockito.Mock; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.mockito.junit.MockitoJUnitRunner; @@ -86,6 +85,7 @@ public class ChatMessageManagerTest "" }; istack = new int[]{ + 0, // splitpmbox 1 }; when(client.getStringStack()).thenReturn(sstack); @@ -183,12 +183,8 @@ public class ChatMessageManagerTest .append("%)") .build(); - MessageNode messageNode = mock(MessageNode.class); - when(messageNode.getType()).thenReturn(ChatMessageType.FRIENDSCHATNOTIFICATION); - when(messageNode.getRuneLiteFormatMessage()).thenReturn(chatMessage); + String formattedMessage = chatMessageManager.formatRuneLiteMessage(chatMessage, ChatMessageType.FRIENDSCHATNOTIFICATION, false); - chatMessageManager.update(messageNode); - - verify(messageNode).setValue("Total points: 42, Personal points: 43 (44%)"); + assertEquals("Total points: 42, Personal points: 43 (44%)", formattedMessage); } } \ No newline at end of file diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java index 918732d049..42d5b729c5 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java @@ -51,7 +51,6 @@ import static net.runelite.api.widgets.WidgetID.DIARY_QUEST_GROUP_ID; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.chat.ChatClient; import net.runelite.client.chat.ChatCommandManager; -import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ChatColorConfig; import net.runelite.client.config.ConfigManager; import net.runelite.client.config.RuneLiteConfig; @@ -105,10 +104,6 @@ public class ChatCommandsPluginTest @Bind HiscoreClient hiscoreClient; - @Mock - @Bind - ChatMessageManager chatMessageManager; - @Mock @Bind ChatClient chatClient; diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java index 518ec09583..13acc51189 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPluginTest.java @@ -37,14 +37,13 @@ import net.runelite.api.MessageNode; import net.runelite.api.Player; import net.runelite.api.events.ChatMessage; import net.runelite.client.Notifier; -import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.util.Text; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; import static org.mockito.ArgumentMatchers.any; +import org.mockito.Mock; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -63,10 +62,6 @@ public class ChatNotificationsPluginTest @Bind private ChatNotificationsConfig config; - @Mock - @Bind - private ChatMessageManager chatMessageManager; - @Mock @Bind private Notifier notifier; @@ -307,7 +302,7 @@ public class ChatNotificationsPluginTest ChatMessage chatMessage = new ChatMessage(messageNode, ChatMessageType.GAMEMESSAGE, "", "", "", 0); chatNotificationsPlugin.onChatMessage(chatMessage); - verify(messageNode).setValue("Logic Knot received a drop: Adamant longsword"); + verify(messageNode).setValue("Logic Knot received a drop: Adamant longsword"); } @Test diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java index fcdc75db13..3fc570c233 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java @@ -54,7 +54,6 @@ import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.Notifier; import net.runelite.client.chat.ChatClient; import net.runelite.client.chat.ChatCommandManager; -import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; import net.runelite.client.game.ItemManager; import net.runelite.client.game.npcoverlay.NpcOverlayService; @@ -158,10 +157,6 @@ public class SlayerPluginTest @Bind Notifier notifier; - @Mock - @Bind - ChatMessageManager chatMessageManager; - @Mock @Bind ChatCommandManager chatCommandManager; @@ -788,14 +783,15 @@ public class SlayerPluginTest when(slayerConfig.taskCommand()).thenReturn(true); when(chatClient.getTask(anyString())).thenReturn(task); + MessageNode messageNode = mock(MessageNode.class); ChatMessage setMessage = new ChatMessage(); setMessage.setType(ChatMessageType.PUBLICCHAT); setMessage.setName("Adam"); - setMessage.setMessageNode(mock(MessageNode.class)); + setMessage.setMessageNode(messageNode); slayerPlugin.taskLookup(setMessage, "!task"); - verify(chatMessageManager).update(any(MessageNode.class)); + verify(messageNode).setRuneLiteFormatMessage(anyString()); } @Test @@ -810,14 +806,15 @@ public class SlayerPluginTest when(slayerConfig.taskCommand()).thenReturn(true); when(chatClient.getTask(anyString())).thenReturn(task); + MessageNode messageNode = mock(MessageNode.class); ChatMessage chatMessage = new ChatMessage(); chatMessage.setType(ChatMessageType.PUBLICCHAT); chatMessage.setName("Adam"); - chatMessage.setMessageNode(mock(MessageNode.class)); + chatMessage.setMessageNode(messageNode); slayerPlugin.taskLookup(chatMessage, "!task"); - verify(chatMessageManager, never()).update(any(MessageNode.class)); + verify(messageNode, never()).setRuneLiteFormatMessage(anyString()); } @Test diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/wintertodt/WintertodtPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/wintertodt/WintertodtPluginTest.java new file mode 100644 index 0000000000..3d57b80a3f --- /dev/null +++ b/runelite-client/src/test/java/net/runelite/client/plugins/wintertodt/WintertodtPluginTest.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2019, Kusha Gharahi + * Copyright (c) 2019, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.wintertodt; + +import com.google.inject.Guice; +import com.google.inject.testing.fieldbinder.Bind; +import com.google.inject.testing.fieldbinder.BoundFieldModule; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.Varbits; +import net.runelite.api.events.VarbitChanged; +import net.runelite.client.Notifier; +import net.runelite.client.ui.overlay.OverlayManager; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class WintertodtPluginTest +{ + @Inject + WintertodtPlugin wintertodtPlugin; + + @Mock + @Bind + WintertodtConfig config; + + @Mock + @Bind + WintertodtOverlay wintertodtOverlay; + + @Mock + @Bind + OverlayManager overlayManager; + + @Mock + @Bind + Notifier notifier; + + @Mock + @Bind + Client client; + + @Before + public void before() + { + Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); + } + + @Test + public void matchStartingNotification_shouldNotify_when15SecondsOptionSelected() + { + when(config.roundNotification()).thenReturn(15); + + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(35); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + //(15 * 50) / 30 = ~25 + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(25); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + + verify(notifier, times(1)).notify("Wintertodt round is about to start"); + } + + @Test + public void matchStartingNotification_shouldNotify_when10SecondsOptionSelected() + { + when(config.roundNotification()).thenReturn(10); + + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(20); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + //(10 * 50) / 30 = ~16 + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(16); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + + verify(notifier, times(1)).notify("Wintertodt round is about to start"); + } + + @Test + public void matchStartingNotification_shouldNotify_when5SecondsOptionSelected() + { + when(config.roundNotification()).thenReturn(5); + + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(10); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + //(5 * 50) / 30 = ~8 + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(8); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + + verify(notifier, times(1)).notify("Wintertodt round is about to start"); + } + + @Test + public void matchStartingNotification_shouldNotifyOnce() + { + when(config.roundNotification()).thenReturn(5); + + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(0); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(10); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(8); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(6); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(5); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(4); + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + + verify(notifier, times(1)).notify("Wintertodt round is about to start"); + } + + @Test + public void matchStartingNotification_shouldNotNotify_whenNoneOptionSelected() + { + when(config.roundNotification()).thenReturn(5); + when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(25); + + wintertodtPlugin.onVarbitChanged(new VarbitChanged()); + verify(notifier, times(0)).notify("Wintertodt round is about to start"); + } +} diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSClanSettingsMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSClanSettingsMixin.java index c75d7dc22d..d181dd7c91 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClanSettingsMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClanSettingsMixin.java @@ -53,7 +53,7 @@ public abstract class RSClanSettingsMixin implements RSClanSettings for (int i = 0; i < memberCount; i++) { - memberList.add(new ClanMember(memberNames[i], client.getClanRankFromRs(memberRanks[i]))); + // memberList.add(new ClanMember(memberNames[i], client.getClanRankFromRs(memberRanks[i]))); } return memberList; @@ -82,7 +82,7 @@ public abstract class RSClanSettingsMixin implements RSClanSettings } else if (compare == 0) { - return new ClanMember(memberName, client.getClanRankFromRs(memberRanks[tag])); + // return new ClanMember(memberName, client.getClanRankFromRs(memberRanks[tag])); } else {