chat message manager: format rl-messages at chat build time
This allows different final messages being built for split chat vs normal chat, fixing <colNORMAL> incorrectly applying the default chatbox color to split chat.
This commit is contained in:
@@ -31,9 +31,7 @@ import com.google.common.collect.HashMultimap;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
@@ -45,9 +43,7 @@ import net.runelite.api.MessageNode;
|
|||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.VarPlayer;
|
import net.runelite.api.VarPlayer;
|
||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.events.ResizeableChanged;
|
|
||||||
import net.runelite.api.events.ScriptCallbackEvent;
|
import net.runelite.api.events.ScriptCallbackEvent;
|
||||||
import net.runelite.api.events.VarbitChanged;
|
|
||||||
import net.runelite.client.callback.ClientThread;
|
import net.runelite.client.callback.ClientThread;
|
||||||
import net.runelite.client.config.ChatColorConfig;
|
import net.runelite.client.config.ChatColorConfig;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
@@ -66,7 +62,6 @@ public class ChatMessageManager
|
|||||||
private final Client client;
|
private final Client client;
|
||||||
private final ChatColorConfig chatColorConfig;
|
private final ChatColorConfig chatColorConfig;
|
||||||
private final ClientThread clientThread;
|
private final ClientThread clientThread;
|
||||||
private int transparencyVarbit = -1;
|
|
||||||
private final Queue<QueuedMessage> queuedMessages = new ConcurrentLinkedQueue<>();
|
private final Queue<QueuedMessage> queuedMessages = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -83,40 +78,25 @@ public class ChatMessageManager
|
|||||||
loadColors();
|
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
|
@Subscribe
|
||||||
public void onConfigChanged(ConfigChanged event)
|
public void onConfigChanged(ConfigChanged event)
|
||||||
{
|
{
|
||||||
if (event.getGroup().equals("textrecolor"))
|
if (event.getGroup().equals("textrecolor"))
|
||||||
{
|
{
|
||||||
loadColors();
|
loadColors();
|
||||||
clientThread.invokeLater(this::refreshAll);
|
clientThread.invokeLater(client::refreshChat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void colorChatMessage()
|
void colorChatMessage()
|
||||||
{
|
{
|
||||||
|
final int[] intStack = client.getIntStack();
|
||||||
final String[] stringStack = client.getStringStack();
|
final String[] stringStack = client.getStringStack();
|
||||||
final int size = client.getStringStackSize();
|
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);
|
final MessageNode messageNode = client.getMessages().get(uid);
|
||||||
assert messageNode != null : "chat message build for unknown message";
|
assert messageNode != null : "chat message build for unknown message";
|
||||||
@@ -184,6 +164,12 @@ public class ChatMessageManager
|
|||||||
stringStack[size - 4] = ColorUtil.wrapWithColorTag(channel, channelColor);
|
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);
|
final Collection<ChatColor> chatColors = colorCache.get(chatMessageType);
|
||||||
for (ChatColor chatColor : chatColors)
|
for (ChatColor chatColor : chatColors)
|
||||||
{
|
{
|
||||||
@@ -824,13 +810,11 @@ public class ChatMessageManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String formattedMessage = formatRuneLiteMessage(message.getRuneLiteFormattedMessage(), message.getType());
|
|
||||||
|
|
||||||
// this updates chat cycle
|
// this updates chat cycle
|
||||||
final MessageNode line = client.addChatMessage(
|
final MessageNode line = client.addChatMessage(
|
||||||
message.getType(),
|
message.getType(),
|
||||||
MoreObjects.firstNonNull(message.getName(), ""),
|
MoreObjects.firstNonNull(message.getName(), ""),
|
||||||
MoreObjects.firstNonNull(formattedMessage, message.getValue()),
|
MoreObjects.firstNonNull(message.getRuneLiteFormattedMessage(), message.getValue()),
|
||||||
message.getSender());
|
message.getSender());
|
||||||
|
|
||||||
// Update the message with RuneLite additions
|
// Update the message with RuneLite additions
|
||||||
@@ -843,64 +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
|
* @param messageNode message node
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void update(final MessageNode messageNode)
|
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))
|
final boolean transparentChatbox = client.getVar(Varbits.TRANSPARENT_CHATBOX) != 0;
|
||||||
{
|
final boolean transparent = client.isResized() && transparentChatbox;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean transparent = client.isResized() && transparencyVarbit != 0;
|
|
||||||
final Collection<ChatColor> chatColors = colorCache.get(type);
|
final Collection<ChatColor> chatColors = colorCache.get(type);
|
||||||
for (ChatColor chatColor : chatColors)
|
for (ChatColor chatColor : chatColors)
|
||||||
{
|
{
|
||||||
if (chatColor.isTransparent() == transparent)
|
if (chatColor.isTransparent() == transparent)
|
||||||
{
|
{
|
||||||
Color color = chatColor.getColor();
|
String colstr;
|
||||||
|
|
||||||
VarPlayer varp = chatColor.getSetting();
|
if (pmbox && chatColor.getType() == ChatColorType.NORMAL)
|
||||||
if (varp != null)
|
|
||||||
{
|
{
|
||||||
// Apply configured color from game settings, if set
|
// The default ChatColors for private have the chatbox text color, not the split chat color,
|
||||||
assert chatColor.isDefault();
|
// and the split chat color is set by widget color, so just use </col>. The in-game
|
||||||
int v = client.getVar(varp);
|
// private chat color doesn't apply to split chat either so using that here also is incorrect.
|
||||||
if (v != 0)
|
//
|
||||||
|
// 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)
|
||||||
{
|
{
|
||||||
color = new Color(v - 1);
|
// 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
|
// Replace custom formatting with actual colors
|
||||||
runeLiteFormatMessage = runeLiteFormatMessage.replaceAll(
|
runeLiteFormatMessage = runeLiteFormatMessage.replaceAll(
|
||||||
"<col" + chatColor.getType().name() + ">",
|
"<col" + chatColor.getType().name() + ">",
|
||||||
ColorUtil.colorTag(color));
|
colstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return runeLiteFormatMessage;
|
return runeLiteFormatMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshAll()
|
|
||||||
{
|
|
||||||
client.getChatLineMap().values().stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.flatMap(clb -> Arrays.stream(clb.getLines()))
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.forEach(this::update);
|
|
||||||
|
|
||||||
client.refreshChat();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ import net.runelite.client.chat.ChatClient;
|
|||||||
import net.runelite.client.chat.ChatColorType;
|
import net.runelite.client.chat.ChatColorType;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
import net.runelite.client.chat.ChatCommandManager;
|
||||||
import net.runelite.client.chat.ChatMessageBuilder;
|
import net.runelite.client.chat.ChatMessageBuilder;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
@@ -175,9 +174,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private ItemManager itemManager;
|
private ItemManager itemManager;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ChatMessageManager chatMessageManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ChatCommandManager chatCommandManager;
|
private ChatCommandManager chatCommandManager;
|
||||||
|
|
||||||
@@ -840,7 +836,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -930,7 +925,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -974,7 +968,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1061,7 +1054,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1137,7 +1129,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1231,7 +1222,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1321,7 +1311,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
|
|
||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1403,7 +1392,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
@@ -1488,7 +1476,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
@@ -1616,7 +1603,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
@@ -1710,7 +1696,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import net.runelite.api.events.ChatMessage;
|
|||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.chat.ChatColorType;
|
import net.runelite.client.chat.ChatColorType;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.ConfigChanged;
|
import net.runelite.client.events.ConfigChanged;
|
||||||
@@ -69,9 +68,6 @@ public class ChatNotificationsPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private ChatNotificationsConfig config;
|
private ChatNotificationsConfig config;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ChatMessageManager chatMessageManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Notifier notifier;
|
private Notifier notifier;
|
||||||
|
|
||||||
@@ -324,7 +320,6 @@ public class ChatNotificationsPlugin extends Plugin
|
|||||||
if (update)
|
if (update)
|
||||||
{
|
{
|
||||||
messageNode.setRuneLiteFormatMessage(messageNode.getValue());
|
messageNode.setRuneLiteFormatMessage(messageNode.getValue());
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -830,7 +830,6 @@ public class RaidsPlugin extends Plugin
|
|||||||
log.debug("Setting response {}", response);
|
log.debug("Setting response {}", response);
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ import net.runelite.client.chat.ChatClient;
|
|||||||
import net.runelite.client.chat.ChatColorType;
|
import net.runelite.client.chat.ChatColorType;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
import net.runelite.client.chat.ChatCommandManager;
|
||||||
import net.runelite.client.chat.ChatMessageBuilder;
|
import net.runelite.client.chat.ChatMessageBuilder;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.ChatInput;
|
import net.runelite.client.events.ChatInput;
|
||||||
@@ -161,9 +160,6 @@ public class SlayerPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private TargetWeaknessOverlay targetWeaknessOverlay;
|
private TargetWeaknessOverlay targetWeaknessOverlay;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ChatMessageManager chatMessageManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ChatCommandManager chatCommandManager;
|
private ChatCommandManager chatCommandManager;
|
||||||
|
|
||||||
@@ -875,7 +871,6 @@ public class SlayerPlugin extends Plugin
|
|||||||
|
|
||||||
final MessageNode messageNode = chatMessage.getMessageNode();
|
final MessageNode messageNode = chatMessage.getMessageNode();
|
||||||
messageNode.setRuneLiteFormatMessage(response);
|
messageNode.setRuneLiteFormatMessage(response);
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ import net.runelite.api.events.GameTick;
|
|||||||
import net.runelite.api.events.ItemContainerChanged;
|
import net.runelite.api.events.ItemContainerChanged;
|
||||||
import net.runelite.api.events.VarbitChanged;
|
import net.runelite.api.events.VarbitChanged;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
@@ -105,9 +104,6 @@ public class WintertodtPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private WintertodtConfig config;
|
private WintertodtConfig config;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ChatMessageManager chatMessageManager;
|
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private WintertodtActivity currentActivity = WintertodtActivity.IDLE;
|
private WintertodtActivity currentActivity = WintertodtActivity.IDLE;
|
||||||
|
|
||||||
@@ -314,7 +310,6 @@ public class WintertodtPlugin extends Plugin
|
|||||||
|
|
||||||
// Recolor message for damage notification
|
// Recolor message for damage notification
|
||||||
messageNode.setRuneLiteFormatMessage(ColorUtil.wrapWithColorTag(messageNode.getValue(), config.damageNotificationColor()));
|
messageNode.setRuneLiteFormatMessage(ColorUtil.wrapWithColorTag(messageNode.getValue(), config.damageNotificationColor()));
|
||||||
chatMessageManager.update(messageNode);
|
|
||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
|
|
||||||
// all actions except woodcutting and idle are interrupted from damage
|
// all actions except woodcutting and idle are interrupted from damage
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class JagexColors
|
|||||||
* Colors of chat text when displayed on an opaque background.
|
* 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_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_TEXT_OPAQUE_BACKGROUND = new Color(127, 0, 0);
|
||||||
public static final Color CHAT_FC_NAME_OPAQUE_BACKGROUND = Color.BLUE;
|
public static final Color CHAT_FC_NAME_OPAQUE_BACKGROUND = Color.BLUE;
|
||||||
public static final Color CHAT_GAME_EXAMINE_TEXT_OPAQUE_BACKGROUND = Color.BLACK;
|
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.
|
* 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_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_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_FC_NAME_TRANSPARENT_BACKGROUND = new Color(144, 112, 255);
|
||||||
public static final Color CHAT_GAME_EXAMINE_TEXT_TRANSPARENT_BACKGROUND = Color.WHITE;
|
public static final Color CHAT_GAME_EXAMINE_TEXT_TRANSPARENT_BACKGROUND = Color.WHITE;
|
||||||
|
|||||||
@@ -440,14 +440,16 @@ LABEL391:
|
|||||||
if_icmpeq LABEL406
|
if_icmpeq LABEL406
|
||||||
jump LABEL1751
|
jump LABEL1751
|
||||||
LABEL406:
|
LABEL406:
|
||||||
|
iconst 0 ; splitpmbox
|
||||||
iload 10 ; message uid
|
iload 10 ; message uid
|
||||||
sload 17 ; message channel
|
sload 17 ; message channel
|
||||||
sload 16 ; message name
|
sload 16 ; message name
|
||||||
sload 18 ; message
|
sload 18 ; message
|
||||||
sload 21 ; message timestamp
|
sload 21 ; message timestamp
|
||||||
sconst "chatMessageBuilding"
|
sconst "chatMessageBuilding"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
pop_int ; pop uid
|
pop_int ; pop uid
|
||||||
|
pop_int ; splitpmbox
|
||||||
sstore 21 ; message timestamp
|
sstore 21 ; message timestamp
|
||||||
sstore 18 ; message
|
sstore 18 ; message
|
||||||
sstore 16 ; message name
|
sstore 16 ; message name
|
||||||
|
|||||||
@@ -413,14 +413,16 @@ CHAT_FILTER:
|
|||||||
if_icmpeq LABEL369 ; Check if we are building this message
|
if_icmpeq LABEL369 ; Check if we are building this message
|
||||||
jump LABEL555
|
jump LABEL555
|
||||||
LABEL369:
|
LABEL369:
|
||||||
|
iconst 1 ; splitpmbox
|
||||||
iload 12 ; message uid
|
iload 12 ; message uid
|
||||||
sconst "" ; message channel
|
sconst "" ; message channel
|
||||||
sload 1 ; message name
|
sload 1 ; message name
|
||||||
sload 0 ; message
|
sload 0 ; message
|
||||||
sload 2 ; message timestamp
|
sload 2 ; message timestamp
|
||||||
sconst "chatMessageBuilding"
|
sconst "chatMessageBuilding"
|
||||||
runelite_callback
|
runelite_callback
|
||||||
pop_int ; uid
|
pop_int ; uid
|
||||||
|
pop_int ; splitpmbox
|
||||||
sstore 2 ; message timestamp
|
sstore 2 ; message timestamp
|
||||||
sstore 0 ; message
|
sstore 0 ; message
|
||||||
sstore 1 ; message name
|
sstore 1 ; message name
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import org.junit.runner.RunWith;
|
|||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
@@ -86,6 +85,7 @@ public class ChatMessageManagerTest
|
|||||||
""
|
""
|
||||||
};
|
};
|
||||||
istack = new int[]{
|
istack = new int[]{
|
||||||
|
0, // splitpmbox
|
||||||
1
|
1
|
||||||
};
|
};
|
||||||
when(client.getStringStack()).thenReturn(sstack);
|
when(client.getStringStack()).thenReturn(sstack);
|
||||||
@@ -183,12 +183,8 @@ public class ChatMessageManagerTest
|
|||||||
.append("%)")
|
.append("%)")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MessageNode messageNode = mock(MessageNode.class);
|
String formattedMessage = chatMessageManager.formatRuneLiteMessage(chatMessage, ChatMessageType.FRIENDSCHATNOTIFICATION, false);
|
||||||
when(messageNode.getType()).thenReturn(ChatMessageType.FRIENDSCHATNOTIFICATION);
|
|
||||||
when(messageNode.getRuneLiteFormatMessage()).thenReturn(chatMessage);
|
|
||||||
|
|
||||||
chatMessageManager.update(messageNode);
|
assertEquals("<col=000000>Total points: <col=ff0000>42<col=000000>, Personal points: <col=ff0000>43<col=000000> (<col=ff0000>44<col=000000>%)", formattedMessage);
|
||||||
|
|
||||||
verify(messageNode).setValue("<col=000000>Total points: <col=ff0000>42<col=000000>, Personal points: <col=ff0000>43<col=000000> (<col=ff0000>44<col=000000>%)");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,6 @@ import static net.runelite.api.widgets.WidgetID.DIARY_QUEST_GROUP_ID;
|
|||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.chat.ChatClient;
|
import net.runelite.client.chat.ChatClient;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
import net.runelite.client.chat.ChatCommandManager;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
|
||||||
import net.runelite.client.config.ChatColorConfig;
|
import net.runelite.client.config.ChatColorConfig;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
@@ -105,10 +104,6 @@ public class ChatCommandsPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
HiscoreClient hiscoreClient;
|
HiscoreClient hiscoreClient;
|
||||||
|
|
||||||
@Mock
|
|
||||||
@Bind
|
|
||||||
ChatMessageManager chatMessageManager;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
ChatClient chatClient;
|
ChatClient chatClient;
|
||||||
|
|||||||
@@ -37,14 +37,13 @@ import net.runelite.api.MessageNode;
|
|||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import org.mockito.Mock;
|
||||||
import static org.mockito.Mockito.lenient;
|
import static org.mockito.Mockito.lenient;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
@@ -63,10 +62,6 @@ public class ChatNotificationsPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
private ChatNotificationsConfig config;
|
private ChatNotificationsConfig config;
|
||||||
|
|
||||||
@Mock
|
|
||||||
@Bind
|
|
||||||
private ChatMessageManager chatMessageManager;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
private Notifier notifier;
|
private Notifier notifier;
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ import net.runelite.api.widgets.WidgetInfo;
|
|||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.chat.ChatClient;
|
import net.runelite.client.chat.ChatClient;
|
||||||
import net.runelite.client.chat.ChatCommandManager;
|
import net.runelite.client.chat.ChatCommandManager;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.game.npcoverlay.NpcOverlayService;
|
import net.runelite.client.game.npcoverlay.NpcOverlayService;
|
||||||
@@ -158,10 +157,6 @@ public class SlayerPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
Notifier notifier;
|
Notifier notifier;
|
||||||
|
|
||||||
@Mock
|
|
||||||
@Bind
|
|
||||||
ChatMessageManager chatMessageManager;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
ChatCommandManager chatCommandManager;
|
ChatCommandManager chatCommandManager;
|
||||||
@@ -788,14 +783,15 @@ public class SlayerPluginTest
|
|||||||
when(slayerConfig.taskCommand()).thenReturn(true);
|
when(slayerConfig.taskCommand()).thenReturn(true);
|
||||||
when(chatClient.getTask(anyString())).thenReturn(task);
|
when(chatClient.getTask(anyString())).thenReturn(task);
|
||||||
|
|
||||||
|
MessageNode messageNode = mock(MessageNode.class);
|
||||||
ChatMessage setMessage = new ChatMessage();
|
ChatMessage setMessage = new ChatMessage();
|
||||||
setMessage.setType(ChatMessageType.PUBLICCHAT);
|
setMessage.setType(ChatMessageType.PUBLICCHAT);
|
||||||
setMessage.setName("Adam");
|
setMessage.setName("Adam");
|
||||||
setMessage.setMessageNode(mock(MessageNode.class));
|
setMessage.setMessageNode(messageNode);
|
||||||
|
|
||||||
slayerPlugin.taskLookup(setMessage, "!task");
|
slayerPlugin.taskLookup(setMessage, "!task");
|
||||||
|
|
||||||
verify(chatMessageManager).update(any(MessageNode.class));
|
verify(messageNode).setRuneLiteFormatMessage(anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -810,14 +806,15 @@ public class SlayerPluginTest
|
|||||||
when(slayerConfig.taskCommand()).thenReturn(true);
|
when(slayerConfig.taskCommand()).thenReturn(true);
|
||||||
when(chatClient.getTask(anyString())).thenReturn(task);
|
when(chatClient.getTask(anyString())).thenReturn(task);
|
||||||
|
|
||||||
|
MessageNode messageNode = mock(MessageNode.class);
|
||||||
ChatMessage chatMessage = new ChatMessage();
|
ChatMessage chatMessage = new ChatMessage();
|
||||||
chatMessage.setType(ChatMessageType.PUBLICCHAT);
|
chatMessage.setType(ChatMessageType.PUBLICCHAT);
|
||||||
chatMessage.setName("Adam");
|
chatMessage.setName("Adam");
|
||||||
chatMessage.setMessageNode(mock(MessageNode.class));
|
chatMessage.setMessageNode(messageNode);
|
||||||
|
|
||||||
slayerPlugin.taskLookup(chatMessage, "!task");
|
slayerPlugin.taskLookup(chatMessage, "!task");
|
||||||
|
|
||||||
verify(chatMessageManager, never()).update(any(MessageNode.class));
|
verify(messageNode, never()).setRuneLiteFormatMessage(anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import net.runelite.api.Client;
|
|||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.events.VarbitChanged;
|
import net.runelite.api.events.VarbitChanged;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -62,10 +61,6 @@ public class WintertodtPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
OverlayManager overlayManager;
|
OverlayManager overlayManager;
|
||||||
|
|
||||||
@Mock
|
|
||||||
@Bind
|
|
||||||
ChatMessageManager chatMessageManager;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
Notifier notifier;
|
Notifier notifier;
|
||||||
|
|||||||
Reference in New Issue
Block a user