Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.net.*;
- import java.io.*;
- import java.util.Vector;
- public class hiscores
- {
- public static final String searchURL = "http://hiscore.runescape.com/index_lite.ws?player=";
- public static final String[] skillName = {"Overall", "Attack", "Defence", "Strength",
- "Constitution", "Ranged", "Prayer", "Magic",
- "Cooking", "Woodcutting", "Fletching", "Fishing",
- "Firemaking", "Crafting", "Smithing", "Mining",
- "Herblore", "Agility", "Thieving", "Slayer",
- "Farming", "Runecrafting", "Hunter", "Construction",
- "Summoning", "Dungeoneering", "Duel Tournament",
- "Bounty Hunters", "Bounty Hunter Rogues",
- "Fist of Guthix", "Mobilising Armies",
- "B.A Attackers", "B.A Defenders", "B.A Collectors",
- "B.A Healers", "Castle Wars Games", "Conquest"};
- public static final String[] skillDataName = {"Rank", "Level", "Experience"};
- public static final int expVSize = skillName.length;
- public static void main(String[] args)
- {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- String keyboard = "";
- while(true)
- {
- System.out.print("Enter rs name: ");
- try
- {
- keyboard = br.readLine();
- if(keyboard.compareTo("`exit") == 0)
- break;
- }
- catch(Exception e)
- {
- System.out.println("Threw a " + e.getClass() + " with message " + e.getMessage());
- }
- System.out.println();
- try
- {
- System.out.println("Looking up hiscores . . .");
- Vector stats = getHiscores(keyboard);
- System.out.println("Found player!");
- System.out.print(rHiscoresToString(stats));
- }
- catch(FileNotFoundException e)
- {
- System.out.println("User not found.");
- }
- catch(Exception e)
- {
- System.out.println("Threw a " + e.getClass() + " with message " + e.getMessage());
- }
- }
- }
- public static String rHiscoresToString(Vector data)
- {
- String formatted = "";
- for(int i = 0; i < expVSize; i++)
- {
- String[] get = (String[])data.get(i);
- formatted = formatted + "[" + skillName[i] + "] ";
- for(int i2 = 0; i2 < get.length; i2++)
- {
- formatted = formatted + skillDataName[i2] + ": " + get[i2] + " || ";
- }
- formatted = formatted + "\n";
- }
- return formatted;
- }
- public static Vector getHiscores(String rsname) throws Exception
- {
- Vector data = new Vector(expVSize);
- URL resultsURL = new URL(searchURL + rsname);
- BufferedReader resultsBuffer = new BufferedReader(new InputStreamReader(resultsURL.openStream()));
- String current = "";
- while((current = resultsBuffer.readLine()) != null)
- {
- data.add(current.split(","));
- }
- resultsBuffer.close();
- return data;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement