diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommands.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommands.java
index f2e87b00db..5f04d66514 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommands.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommands.java
@@ -26,9 +26,11 @@
package net.runelite.client.plugins.chatcommands;
import com.google.common.eventbus.Subscribe;
+import java.awt.Color;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
+import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.MessageNode;
@@ -104,7 +106,7 @@ public class ChatCommands extends Plugin
logger.debug("Running price lookup for {}", search);
ScheduledExecutorService executor = runelite.getExecutor();
- executor.submit(() -> lookup(setMessage.getMessageNode(), search));
+ executor.submit(() -> lookup(setMessage.getType(), setMessage.getMessageNode(), search));
}
else if (config.lvl() && message.toLowerCase().startsWith("!lvl") && message.length() > 5)
{
@@ -112,7 +114,7 @@ public class ChatCommands extends Plugin
logger.debug("Running level lookup for {}", search);
ScheduledExecutorService executor = runelite.getExecutor();
- executor.submit(() -> playerSkillLookup(setMessage, search));
+ executor.submit(() -> playerSkillLookup(setMessage.getType(), setMessage, search));
}
}
@@ -123,7 +125,7 @@ public class ChatCommands extends Plugin
* @param messageNode The chat message containing the command.
* @param search The item given with the command.
*/
- private void lookup(MessageNode messageNode, String search)
+ private void lookup(ChatMessageType type, MessageNode messageNode, String search)
{
SearchResult result;
@@ -159,14 +161,29 @@ public class ChatCommands extends Plugin
return;
}
+ Color color1 = getColor(type),
+ color2 = getColorH(type);
+
+ String hexColor1 = "", hexColor2 = "";
+
+ if (config.recolorEnabled() && color1 != null && color2 != null)
+ {
+ hexColor1 = toHexCol(color1);
+ hexColor2 = toHexCol(color2);
+ }
+
StringBuilder builder = new StringBuilder();
- builder.append("Price of ").append(item.getName()).append(": GE average ").append(String.format("%,d", itemPrice.getPrice()));
+ builder.append("
").append("Price of ")
+ .append("").append(item.getName())
+ .append("").append(": GE average ")
+ .append("").append(String.format("%,d", itemPrice.getPrice()));
ItemComposition itemComposition = client.getItemDefinition(itemId);
if (itemComposition != null)
{
int alchPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT);
- builder.append(" HA value ").append(alchPrice);
+ builder.append("").append(" HA value ")
+ .append("").append(String.format("%,d", alchPrice));
}
logger.debug("Setting response {}", builder.toString());
@@ -184,7 +201,7 @@ public class ChatCommands extends Plugin
* @param setMessage The chat message containing the command.
* @param search The item given with the command.
*/
- private void playerSkillLookup(SetMessage setMessage, String search)
+ private void playerSkillLookup(ChatMessageType type, SetMessage setMessage, String search)
{
String player = sanitize(setMessage.getName());
@@ -211,10 +228,24 @@ public class ChatCommands extends Plugin
SingleHiscoreSkillResult result = hiscoreClient.lookup(player, skill);
Skill hiscoreSkill = result.getSkill();
- String response = new StringBuilder().append("Level ").append(skill.getName()).append(": ")
- .append(hiscoreSkill.getLevel())
- .append(" Experience: ").append(String.format("%,d", hiscoreSkill.getExperience()))
- .append(" Rank: ").append(String.format("%,d", hiscoreSkill.getRank()))
+ Color color1 = getColor(type),
+ color2 = getColorH(type);
+
+ String hexColor1 = "", hexColor2 = "";
+
+ if (config.recolorEnabled() && color1 != null && color2 != null)
+ {
+ hexColor1 = toHexCol(color1);
+ hexColor2 = toHexCol(color2);
+ }
+
+ String response = new StringBuilder()
+ .append("").append("Level ")
+ .append("").append(skill.getName()).append(": ").append(hiscoreSkill.getLevel())
+ .append("").append(" Experience: ")
+ .append("").append(String.format("%,d", hiscoreSkill.getExperience()))
+ .append("").append(" Rank: ")
+ .append("").append(String.format("%,d", hiscoreSkill.getRank()))
.toString();
logger.debug("Setting response {}", response);
@@ -250,6 +281,42 @@ public class ChatCommands extends Plugin
return null;
}
+ private Color getColor(ChatMessageType type)
+ {
+ switch (type)
+ {
+ case PUBLIC:
+ return config.getPublicRecolor();
+ case CLANCHAT:
+ return config.getCcRecolor();
+ case PRIVATE_MESSAGE_RECEIVED:
+ case PRIVATE_MESSAGE_SENT:
+ return config.getPrivateRecolor();
+ }
+ return null;
+ }
+
+ private Color getColorH(ChatMessageType type)
+ {
+ switch (type)
+ {
+ case PUBLIC:
+ return config.getPublicHRecolor();
+ case CLANCHAT:
+ return config.getCcHRecolor();
+ case PRIVATE_MESSAGE_RECEIVED:
+ case PRIVATE_MESSAGE_SENT:
+ return config.getPrivateHRecolor();
+ }
+ return null;
+ }
+
+ private static String toHexCol(Color color)
+ {
+ // doesn't support alpha
+ return color == null ? "" : Integer.toHexString(color.getRGB() & 0xFFFFFF);
+ }
+
/**
* Cleans the playername string from ironman status icon if present and
* corrects spaces
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java
index 54d3c69837..407d9b4e41 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsConfig.java
@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.chatcommands;
+import java.awt.Color;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@@ -53,4 +54,74 @@ public interface ChatCommandsConfig
{
return true;
}
+
+ @ConfigItem(
+ keyName = "enableRecolor",
+ name = "Enable command recolor",
+ description = "Configures whether chat commands are recolored"
+ )
+ default boolean recolorEnabled()
+ {
+ return true;
+ }
+
+ @ConfigItem(
+ keyName = "hexColorPublic",
+ name = "Public chat",
+ description = "Color of Public chat"
+ )
+ default Color getPublicRecolor()
+ {
+ return Color.decode("#0000FF");
+ }
+
+ @ConfigItem(
+ keyName = "hexColorPublicH",
+ name = "Public chat highlight",
+ description = "Color of Public chat highlight"
+ )
+ default Color getPublicHRecolor()
+ {
+ return Color.decode("#000000");
+ }
+
+ @ConfigItem(
+ keyName = "hexColorPrivate",
+ name = "Private chat",
+ description = "Color of Private chat"
+ )
+ default Color getPrivateRecolor()
+ {
+ return Color.decode("#0088FF");
+ }
+
+ @ConfigItem(
+ keyName = "hexColorPrivateH",
+ name = "Private chat highlight",
+ description = "Color of Private chat highlight"
+ )
+ default Color getPrivateHRecolor()
+ {
+ return Color.decode("#002783");
+ }
+
+ @ConfigItem(
+ keyName = "hexColorCc",
+ name = "Clan chat",
+ description = "Color of Clan chat"
+ )
+ default Color getCcRecolor()
+ {
+ return Color.decode("#900000");
+ }
+
+ @ConfigItem(
+ keyName = "hexColorCcH",
+ name = "Clan chat Highlight",
+ description = "Color of Clan chat highlight"
+ )
+ default Color getCcHRecolor()
+ {
+ return Color.decode("#000000");
+ }
}