use of net.runelite.http.api.hiscore.SingleHiscoreSkillResult in project runelite by runelite.
the class ChatCommandsPlugin method playerSkillLookup.
/**
* Looks up the player skill and changes the original message to the
* response.
*
* @param setMessage The chat message containing the command.
* @param search The item given with the command.
*/
private void playerSkillLookup(ChatMessageType type, SetMessage setMessage, String search) {
search = SkillAbbreviations.getFullName(search);
String player;
if (type.equals(ChatMessageType.PRIVATE_MESSAGE_SENT)) {
player = client.getLocalPlayer().getName();
} else {
player = sanitize(setMessage.getName());
}
HiscoreSkill skill;
try {
skill = HiscoreSkill.valueOf(search.toUpperCase());
} catch (IllegalArgumentException i) {
return;
}
try {
SingleHiscoreSkillResult result = hiscoreClient.lookup(player, skill);
Skill hiscoreSkill = result.getSkill();
String response = 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();
log.debug("Setting response {}", response);
final MessageNode messageNode = setMessage.getMessageNode();
messageNode.setRuneLiteFormatMessage(response);
chatMessageManager.update(messageNode);
client.refreshChat();
} catch (IOException ex) {
log.warn("unable to look up skill {} for {}", skill, search, ex);
}
}
use of net.runelite.http.api.hiscore.SingleHiscoreSkillResult in project runelite by runelite.
the class HiscoreController method singleSkillLookup.
@RequestMapping("/{endpoint}/{skillName}")
public SingleHiscoreSkillResult singleSkillLookup(@PathVariable HiscoreEndpoint endpoint, @PathVariable String skillName, @RequestParam String username) throws IOException {
HiscoreSkill skill = HiscoreSkill.valueOf(skillName.toUpperCase());
// RS api only supports looking up all stats
HiscoreResultBuilder result = hiscoreService.lookupUsername(username, endpoint);
// Find the skill to return
Skill requested = result.getSkill(skill.ordinal());
SingleHiscoreSkillResult skillResult = new SingleHiscoreSkillResult();
skillResult.setPlayer(username);
skillResult.setSkillName(skillName);
skillResult.setSkill(requested);
return skillResult;
}
Aggregations