chatcommands: fix showing -1 experience/rank in lvl

This commit is contained in:
Adam
2020-03-22 14:24:52 -04:00
parent 0ee189cf9d
commit 5da84178e7
2 changed files with 102 additions and 33 deletions

View File

@@ -55,8 +55,8 @@ import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.vars.AccountType;
import net.runelite.api.widgets.Widget;
import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID;
import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.COUNTERS_LOG_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.chat.ChatColorType;
import net.runelite.client.chat.ChatCommandManager;
@@ -119,7 +119,6 @@ public class ChatCommandsPlugin extends Plugin
@VisibleForTesting
static final int ADV_LOG_EXPLOITS_TEXT_INDEX = 1;
private final HiscoreClient hiscoreClient = new HiscoreClient();
private final ChatClient chatClient = new ChatClient();
private boolean bossLogLoaded;
@@ -157,6 +156,9 @@ public class ChatCommandsPlugin extends Plugin
@Inject
private ChatKeyboardListener chatKeyboardListener;
@Inject
private HiscoreClient hiscoreClient;
@Override
public void startUp()
{
@@ -1005,21 +1007,27 @@ public class ChatCommandsPlugin extends Plugin
final Skill hiscoreSkill = result.getSkill();
final String response = new ChatMessageBuilder()
ChatMessageBuilder chatMessageBuilder = new ChatMessageBuilder()
.append(ChatColorType.NORMAL)
.append("Level ")
.append(ChatColorType.HIGHLIGHT)
.append(skill.getName()).append(": ").append(String.valueOf(hiscoreSkill.getLevel()))
.append(ChatColorType.NORMAL)
.append(" Experience: ")
.append(ChatColorType.HIGHLIGHT)
.append(String.format("%,d", hiscoreSkill.getExperience()))
.append(ChatColorType.NORMAL)
.append(" Rank: ")
.append(ChatColorType.HIGHLIGHT)
.append(String.format("%,d", hiscoreSkill.getRank()))
.build();
.append(ChatColorType.NORMAL);
if (hiscoreSkill.getExperience() != -1)
{
chatMessageBuilder.append(" Experience: ")
.append(ChatColorType.HIGHLIGHT)
.append(String.format("%,d", hiscoreSkill.getExperience()))
.append(ChatColorType.NORMAL);
}
if (hiscoreSkill.getRank() != -1)
{
chatMessageBuilder.append(" Rank: ")
.append(ChatColorType.HIGHLIGHT)
.append(String.format("%,d", hiscoreSkill.getRank()));
}
final String response = chatMessageBuilder.build();
log.debug("Setting response {}", response);
final MessageNode messageNode = chatMessage.getMessageNode();
messageNode.setRuneLiteFormatMessage(response);