chat message manager: fix gim rl-format messages

The rl-format messages aren't prepended with |, causing them to be sent to normal clan chat instead.
This commit is contained in:
Adam
2022-03-15 15:30:19 -04:00
parent 310b007409
commit e953631a08
2 changed files with 34 additions and 10 deletions

View File

@@ -164,9 +164,16 @@ public class ChatMessageManager
stringStack[size - 4] = ColorUtil.wrapWithColorTag(channel, channelColor);
}
String prefix = "";
if (chatMessageType == ChatMessageType.CLAN_GIM_CHAT || chatMessageType == ChatMessageType.CLAN_GIM_MESSAGE)
{
message = message.substring(1); // remove |
prefix = "|";
}
if (messageNode.getRuneLiteFormatMessage() != null)
{
stringStack[size - 2] = message = formatRuneLiteMessage(messageNode.getRuneLiteFormatMessage(),
message = formatRuneLiteMessage(messageNode.getRuneLiteFormatMessage(),
chatMessageType, splitpmbox);
}
@@ -178,20 +185,15 @@ public class ChatMessageManager
continue;
}
String prefix = "";
if (chatMessageType == ChatMessageType.CLAN_GIM_CHAT || chatMessageType == ChatMessageType.CLAN_GIM_MESSAGE)
{
message = message.substring(1); // remove |
prefix = "|";
}
// Replace </col> tags in the message with the new color so embedded </col> won't reset the color
final Color color = chatColor.getColor();
stringStack[size - 2] = prefix + ColorUtil.wrapWithColorTag(
message = ColorUtil.wrapWithColorTag(
message.replace(ColorUtil.CLOSING_COLOR_TAG, ColorUtil.colorTag(color)),
color);
break;
}
stringStack[size - 2] = prefix + message;
}
@Subscribe

View File

@@ -69,7 +69,7 @@ public class ChatMessageManagerTest
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
}
private void setupVm(ChatMessageType type, String name, String message)
private MessageNode setupVm(ChatMessageType type, String name, String message)
{
MessageNode messageNode = mock(MessageNode.class);
when(messageNode.getType()).thenReturn(type);
@@ -92,6 +92,8 @@ public class ChatMessageManagerTest
when(client.getStringStackSize()).thenReturn(sstack.length);
when(client.getIntStack()).thenReturn(istack);
when(client.getIntStackSize()).thenReturn(istack.length);
return messageNode;
}
@Test
@@ -187,4 +189,24 @@ public class ChatMessageManagerTest
assertEquals("<col=000000>Total points: <col=ff0000>42<col=000000>, Personal points: <col=ff0000>43<col=000000> (<col=ff0000>44<col=000000>%)", formattedMessage);
}
@Test
public void testGim()
{
when(chatColorConfig.opaqueClanChatInfo()).thenReturn(Color.RED);
when(chatColorConfig.opaqueClanChatInfoHighlight()).thenReturn(Color.BLUE);
// rebuild color cache
ConfigChanged configChanged = new ConfigChanged();
configChanged.setGroup("textrecolor");
chatMessageManager.onConfigChanged(configChanged);
MessageNode messageNode = setupVm(ChatMessageType.CLAN_GIM_MESSAGE, "", "rsn received a drop: 8 x Bronze bolts (16 coins).");
when(messageNode.getRuneLiteFormatMessage()).thenReturn("<colHIGHLIGHT><u>rsn</u><colNORMAL> received a drop: 8 x Bronze bolts (16 coins).");
chatMessageManager.colorChatMessage();
// | <chat color> <highlight color>
assertEquals("|<col=ff0000><col=0000ff><u>rsn</u><col=ff0000> received a drop: 8 x Bronze bolts (16 coins).</col>", sstack[2]);
}
}