chat message manager: Use ColorUtil functions
This commit is contained in:
@@ -51,6 +51,7 @@ import net.runelite.api.events.ResizeableChanged;
|
|||||||
import net.runelite.api.events.SetMessage;
|
import net.runelite.api.events.SetMessage;
|
||||||
import net.runelite.api.events.VarbitChanged;
|
import net.runelite.api.events.VarbitChanged;
|
||||||
import net.runelite.client.config.ChatColorConfig;
|
import net.runelite.client.config.ChatColorConfig;
|
||||||
|
import net.runelite.client.util.ColorUtil;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -145,13 +146,13 @@ public class ChatMessageManager
|
|||||||
|
|
||||||
if (usernameColor != null)
|
if (usernameColor != null)
|
||||||
{
|
{
|
||||||
messageNode.setName(wrapTextWithColour(messageNode.getName(), usernameColor));
|
messageNode.setName(ColorUtil.wrapWithColorTag(messageNode.getName(), usernameColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
String sender = setMessage.getSender();
|
String sender = setMessage.getSender();
|
||||||
if (senderColor != null && !Strings.isNullOrEmpty(sender))
|
if (senderColor != null && !Strings.isNullOrEmpty(sender))
|
||||||
{
|
{
|
||||||
messageNode.setSender(wrapTextWithColour(sender, senderColor));
|
messageNode.setSender(ColorUtil.wrapWithColorTag(sender, senderColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
final Collection<ChatColor> chatColors = colorCache.get(chatMessageType);
|
final Collection<ChatColor> chatColors = colorCache.get(chatMessageType);
|
||||||
@@ -162,16 +163,11 @@ public class ChatMessageManager
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
messageNode.setValue(wrapTextWithColour(messageNode.getValue(), chatColor.getColor()));
|
messageNode.setValue(ColorUtil.wrapWithColorTag(messageNode.getValue(), chatColor.getColor()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String wrapTextWithColour(String text, Color colour)
|
|
||||||
{
|
|
||||||
return "<col=" + Integer.toHexString(colour.getRGB() & 0xFFFFFF) + ">" + text + "</col>";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Color getDefaultColor(ChatMessageType type, boolean transparent)
|
private static Color getDefaultColor(ChatMessageType type, boolean transparent)
|
||||||
{
|
{
|
||||||
if (!transparent)
|
if (!transparent)
|
||||||
@@ -566,7 +562,7 @@ public class ChatMessageManager
|
|||||||
.forEach(chatColor ->
|
.forEach(chatColor ->
|
||||||
resultMessage.getAndUpdate(oldMessage -> oldMessage.replaceAll(
|
resultMessage.getAndUpdate(oldMessage -> oldMessage.replaceAll(
|
||||||
"<col" + chatColor.getType().name() + ">",
|
"<col" + chatColor.getType().name() + ">",
|
||||||
"<col=" + Integer.toHexString(chatColor.getColor().getRGB() & 0xFFFFFF) + ">")));
|
ColorUtil.colorTag(chatColor.getColor()))));
|
||||||
|
|
||||||
return resultMessage.get();
|
return resultMessage.get();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user