Search in sources :

Example 1 with HiscoreEndpoint

use of net.runelite.http.api.hiscore.HiscoreEndpoint in project runelite by runelite.

the class HiscorePanel method lookup.

private void lookup() {
    String lookup = input.getText();
    details.setText("Loading...");
    lookup = sanitize(lookup);
    if (Strings.isNullOrEmpty(lookup)) {
        return;
    }
    for (JLabel label : skillLabels) {
        label.setText("--");
    }
    try {
        HiscoreEndpoint endpoint = HiscoreEndpoint.valueOf(endpointButtonGroup.getSelection().getActionCommand());
        log.debug("Hiscore endpoint " + endpoint.name() + " selected");
        result = client.lookup(lookup, endpoint);
    } catch (IOException ex) {
        log.warn("Error fetching Hiscore data " + ex.getMessage());
        details.setText("Error fetching Hiscore data");
        return;
    }
    for (JLabel label : skillLabels) {
        String skillName = (String) label.getClientProperty(SKILL_NAME);
        HiscoreSkill skill = (HiscoreSkill) label.getClientProperty(SKILL);
        if (skillName.equals("Combat")) {
            if (result.getPlayer() != null) {
                int combatLevel = Experience.getCombatLevel(result.getAttack().getLevel(), result.getStrength().getLevel(), result.getDefence().getLevel(), result.getHitpoints().getLevel(), result.getMagic().getLevel(), result.getRanged().getLevel(), result.getPrayer().getLevel());
                label.setText(Integer.toString(combatLevel));
            }
        } else if (result.getSkill(skill) != null && result.getSkill(skill).getRank() != -1) {
            label.setText(Integer.toString(result.getSkill(skill).getLevel()));
        }
    }
    // Clear details panel
    details.setFont(UIManager.getFont("Label.font").deriveFont(Font.ITALIC));
    details.setText("Hover over a skill for details");
}
Also used : JLabel(javax.swing.JLabel) IOException(java.io.IOException) HiscoreEndpoint(net.runelite.http.api.hiscore.HiscoreEndpoint) HiscoreSkill(net.runelite.http.api.hiscore.HiscoreSkill) HiscoreEndpoint(net.runelite.http.api.hiscore.HiscoreEndpoint)

Aggregations

IOException (java.io.IOException)1 JLabel (javax.swing.JLabel)1 HiscoreEndpoint (net.runelite.http.api.hiscore.HiscoreEndpoint)1 HiscoreSkill (net.runelite.http.api.hiscore.HiscoreSkill)1