Jump to content

HighScores - Other Players


Malcolm

Recommended Posts

Good use-cases are for stakers to check stats of other players, pkers, etc, Mostly PvP usages.

 

USAGE:
 

        Highscores highscores = new Highscores("Zezima");
        System.out.println(highscores.getSkillLevel(Skill.HERBLORE));

CODE:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;

import org.osbot.rs07.api.ui.Skill;

import java.net.MalformedURLException;
import java.util.ArrayList;

public class Highscores {

	private final ArrayList<String> stats = new ArrayList<String>();

	public Highscores(final String player) {
		getStats(player);
	}

	public int getSkillLevel(final Skill skill) {
		int index = getSkillIndex(skill);
		String[] array = stats.get(index).split(",");
		return Integer.parseInt(array[1]);
	}

	public int getSkillExperience(final Skill skill) {
		int index = getSkillIndex(skill);
		String[] array = stats.get(index).split(",");
		return Integer.parseInt(array[2]);
	}

	private void getStats(final String player) {
		try {
			URL url = new URL("https://secure.runescape.com/m=hiscore_oldschool/index_lite.ws?player=" + player);
			URLConnection con = url.openConnection();
			BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

			String inputLine;
			while ((inputLine = in.readLine()) != null) {
				stats.add(inputLine);
			}
			in.close();
		} catch (MalformedURLException e) {
			// CATCH
		} catch (IOException e) {
			// CATCH
		}
	}

	private int getSkillIndex(final Skill skill) {
		return Arrays.asList(Skill.values()).indexOf(skill) + 1;
	}
}
  • Like 1
  • Boge 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...