Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2022-01-16 02:09:51 +01:00
21 changed files with 410 additions and 201 deletions

View File

@@ -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);
}
}

View File

@@ -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<QueuedMessage> 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<ChatColor> 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<ChatColor> 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 </col>. 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 </col> 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(
"<col" + chatColor.getType().name() + ">",
colstr);
}
}
final AtomicReference<String> resultMessage = new AtomicReference<>(runeLiteFormatMessage);
// Replace custom formatting with actual colors
chatColors.stream()
.filter(chatColor -> chatColor.isTransparent() == transparent)
.forEach(chatColor ->
resultMessage.getAndUpdate(oldMessage -> oldMessage.replaceAll(
"<col" + chatColor.getType().name() + ">",
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;
}
}

View File

@@ -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)

View File

@@ -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)), "</col>");
final String replacement = "<col" + ChatColorType.HIGHLIGHT.name() + "><u>" + username + "</u>" + 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)),
"<col" + ChatColorType.NORMAL + '>');
final String replacement = "<col" + ChatColorType.HIGHLIGHT.name() + "><u>" + username + "</u>" + 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 + <content between last match and current match>
// 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)),
"<col" + ChatColorType.NORMAL + '>');
// 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, "<col" + ChatColorType.HIGHLIGHT + '>' + value);
if (endColor == null)
{
endColor = getLastColor(stringBuffer.toString());
}
// Append end color
stringBuffer.append(endColor == null ? "<col" + ChatColorType.NORMAL + ">" : endColor);
matcher.appendReplacement(stringBuffer, "<col" + ChatColorType.HIGHLIGHT + '>' + value + closeColor);
update = true;
matchesHighlight = true;
@@ -322,7 +320,6 @@ public class ChatNotificationsPlugin extends Plugin
if (update)
{
messageNode.setRuneLiteFormatMessage(messageNode.getValue());
chatMessageManager.update(messageNode);
}
}

View File

@@ -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",

View File

@@ -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<Rectangle, GroundItem> 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)
{
// <col=ff9040>Logs
// <col=00ff00>Telekinetic Grab</col><col=ffffff> -> <col=ff9040>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);
}
}
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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("<col=000000>Total points: <col=ff0000>42<col=000000>, Personal points: <col=ff0000>43<col=000000> (<col=ff0000>44<col=000000>%)");
assertEquals("<col=000000>Total points: <col=ff0000>42<col=000000>, Personal points: <col=ff0000>43<col=000000> (<col=ff0000>44<col=000000>%)", formattedMessage);
}
}

View File

@@ -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;

View File

@@ -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("<colHIGHLIGHT><u>Logic Knot</u></col> received a drop: Adamant longsword");
verify(messageNode).setValue("<colHIGHLIGHT><u>Logic Knot</u><colNORMAL> received a drop: Adamant longsword");
}
@Test

View File

@@ -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

View File

@@ -0,0 +1,150 @@
/*
* Copyright (c) 2019, Kusha Gharahi<kusha.me>
* Copyright (c) 2019, Adam <Adam@sigterm.info>
* 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");
}
}