progamerz Posted June 27, 2016 Share Posted June 27, 2016 (edited) Thanks @LoudPacks,@Explv and @Cyberus. Usage: //Grabbing level getSkill("Acc_name", SKILL_ID).getLevel(); //Grabbing EXP getSkill("Acc_name", SKILL_ID).getXp(); Highscore.java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; public final class Highscores { public static String username; private Highscores() { } private static final String BASE_URL = "http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player="; private static final int SKILL_COUNT = 24; private static final int ACTIVITY_COUNT = 3; public static Skill[] getSkills(final String playerName) { Skill[] skills = new Skill[SKILL_COUNT]; try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(new StringBuffer(BASE_URL).append(URLEncoder.encode(playerName.replace((char)160, ' '), "UTF-8")).toString()).openStream()))) { for (int skill = 0; skill < SKILL_COUNT; skill++) { String[] skillEncodedSplit = reader.readLine().split(","); skills[skill] = new Skill(Integer.parseInt(skillEncodedSplit[0]), Integer.parseInt(skillEncodedSplit[1]), Integer.parseInt(skillEncodedSplit[2])); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return skills; } public static Skill getSkill(final String playerName, int skillId) { return getSkills(playerName)[skillId]; } public static Activity[] getActivities(final String playerName) { try { final Activity[] activities = new Activity[ACTIVITY_COUNT]; try (final BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(new StringBuffer(BASE_URL).append(playerName).toString()).openStream()))) { for (int skill = 0; skill < SKILL_COUNT; skill++) { reader.readLine(); } for (int activity = 0; activity < ACTIVITY_COUNT; activity++) { final String[] activityEncodedSplit = reader.readLine().split(","); activities[activity] = new Activity(Integer.parseInt(activityEncodedSplit[0]), Integer.parseInt(activityEncodedSplit[1])); } } return activities; } catch (final IOException e) { throw new IllegalArgumentException("Username not valid"); } } public static Activity getActivity(final String playerName, int activityId) { return getActivities(playerName)[activityId]; } public static class Skill { private final int rank; private final int level; private final int xp; private Skill(final int rank, final int level, final int xp) { this.rank = rank; this.level = level; this.xp = xp; } public int getRank() { return rank; } public int getLevel() { return level; } public int getXp() { return xp; } } public static class Activity { private final int rank; private final int score; private Activity(final int rank, final int score) { this.rank = rank; this.score = score; } public int getRank() { return rank; } public int getScore() { return score; } } } Edited June 27, 2016 by progamerz Quote Link to comment Share on other sites More sharing options...
Explv Posted June 27, 2016 Share Posted June 27, 2016 (edited) Runescape has an official Highscores API that you can make use of Here is an example of how you could use it: public final Map<String, Stat> getStats(final String playerName) { final Map<String, Stat> stats = new HashMap<>(24); try { URL url = new URL("http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=" + playerName); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); try(InputStreamReader inputStreamReader = new InputStreamReader(con.getInputStream()); BufferedReader br = new BufferedReader(inputStreamReader)) { String[] splitVals = br.readLine().split(","); Stat overallStat = new Stat(Integer.parseInt(splitVals[0]), Integer.parseInt(splitVals[1]), Integer.parseInt(splitVals[2])); stats.put("Overall", overallStat); for (final Skill skill : Skill.values()) { splitVals = br.readLine().split(","); stats.put(skill.toString(), new Stat(Integer.parseInt(splitVals[0]), Integer.parseInt(splitVals[1]), Integer.parseInt(splitVals[2]))); } } } catch(final Exception e){ e.printStackTrace(); } return stats; } Where Stat is: public final class Stat { private final int rank, level, xp; public Stat(final int rank, final int level, final int xp) { this.rank = rank; this.level = level; this.xp = xp; } public final int getRank() { return rank; } public final int getLevel() { return level; } public final int getXp() { return xp; } @Override public final String toString() { return String.format("Rank: %d, Level: %d, XP: %d", rank, level, xp); } } Testing: getStats("zezima").forEach((s, stat) -> System.out.println(s + " " + stat.toString())); Output: Overall Rank: 1044122, Level: 263, XP: 171029 Hunter Rank: 469487, Level: 1, XP: 0 Thieving Rank: 727948, Level: 13, XP: 1872 Construction Rank: 379600, Level: 1, XP: 0 Cooking Rank: 729252, Level: 31, XP: 14890 Magic Rank: 1254581, Level: 2, XP: 110 Fletching Rank: 409758, Level: 37, XP: 27502 Herblore Rank: 619712, Level: 1, XP: 0 Firemaking Rank: 370103, Level: 43, XP: 50460 Attack Rank: 1488162, Level: 7, XP: 652 Fishing Rank: 800753, Level: 24, XP: 7030 Crafting Rank: 961015, Level: 3, XP: 230 Hitpoints Rank: 1623703, Level: 13, XP: 1989 Ranged Rank: -1, Level: 1, XP: 4 Mining Rank: 1002037, Level: 13, XP: 2047 Runecrafting Rank: 511420, Level: 1, XP: 0 Smithing Rank: 1455957, Level: 1, XP: 18 Agility Rank: 829188, Level: 1, XP: 0 Woodcutting Rank: 596579, Level: 44, XP: 61130 Slayer Rank: 786552, Level: 1, XP: 10 Defence Rank: 1391507, Level: 1, XP: 36 Strength Rank: 1382147, Level: 13, XP: 1848 Prayer Rank: 1097298, Level: 10, XP: 1201 Farming Rank: 487599, Level: 1, XP: 0 Edited June 27, 2016 by Explv 1 Quote Link to comment Share on other sites More sharing options...
progamerz Posted June 27, 2016 Author Share Posted June 27, 2016 Runescape has an official Highscores API that you can make use of Here is an example of how you could use it: public final Map<String, Stat> getStats(final String playerName) { final Map<String, Stat> stats = new HashMap<>(24); try { URL url = new URL("http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=" + playerName); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); try(InputStreamReader inputStreamReader = new InputStreamReader(con.getInputStream()); BufferedReader br = new BufferedReader(inputStreamReader)) { String[] splitVals = br.readLine().split(","); Stat overallStat = new Stat(Integer.parseInt(splitVals[0]), Integer.parseInt(splitVals[1]), Integer.parseInt(splitVals[2])); stats.put("Overall", overallStat); for (final Skill skill : Skill.values()) { splitVals = br.readLine().split(","); stats.put(skill.toString(), new Stat(Integer.parseInt(splitVals[0]), Integer.parseInt(splitVals[1]), Integer.parseInt(splitVals[2]))); } } } catch(final Exception e){ e.printStackTrace(); } return stats; } Where Stat is: public final class Stat { private final int rank, level, xp; public Stat(final int rank, final int level, final int xp) { this.rank = rank; this.level = level; this.xp = xp; } public final int getRank() { return rank; } public final int getLevel() { return level; } public final int getXp() { return xp; } @Override public final String toString() { return String.format("Rank: %d, Level: %d, XP: %d", rank, level, xp); } } Testing: getStats("zezima").forEach((s, stat) -> System.out.println(s + " " + stat.toString())); Output: Overall Rank: 1044122, Level: 263, XP: 171029 Hunter Rank: 469487, Level: 1, XP: 0 Thieving Rank: 727948, Level: 13, XP: 1872 Construction Rank: 379600, Level: 1, XP: 0 Cooking Rank: 729252, Level: 31, XP: 14890 Magic Rank: 1254581, Level: 2, XP: 110 Fletching Rank: 409758, Level: 37, XP: 27502 Herblore Rank: 619712, Level: 1, XP: 0 Firemaking Rank: 370103, Level: 43, XP: 50460 Attack Rank: 1488162, Level: 7, XP: 652 Fishing Rank: 800753, Level: 24, XP: 7030 Crafting Rank: 961015, Level: 3, XP: 230 Hitpoints Rank: 1623703, Level: 13, XP: 1989 Ranged Rank: -1, Level: 1, XP: 4 Mining Rank: 1002037, Level: 13, XP: 2047 Runecrafting Rank: 511420, Level: 1, XP: 0 Smithing Rank: 1455957, Level: 1, XP: 18 Agility Rank: 829188, Level: 1, XP: 0 Woodcutting Rank: 596579, Level: 44, XP: 61130 Slayer Rank: 786552, Level: 1, XP: 10 Defence Rank: 1391507, Level: 1, XP: 36 Strength Rank: 1382147, Level: 13, XP: 1848 Prayer Rank: 1097298, Level: 10, XP: 1201 Farming Rank: 487599, Level: 1, XP: 0 Thanks Quote Link to comment Share on other sites More sharing options...
LoudPacks Posted June 27, 2016 Share Posted June 27, 2016 (edited) Coming thru with the DANKS: package com.loudpacks.script.util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; public final class Highscores { public static String username; private Highscores() { } private static final String BASE_URL = "http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player="; private static final int SKILL_COUNT = 24; private static final int ACTIVITY_COUNT = 3; public static Skill[] getSkills(final String playerName) { Skill[] skills = new Skill[SKILL_COUNT]; try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(new StringBuffer(BASE_URL).append(URLEncoder.encode(playerName.replace((char)160, ' '), "UTF-8")).toString()).openStream()))) { for (int skill = 0; skill < SKILL_COUNT; skill++) { String[] skillEncodedSplit = reader.readLine().split(","); skills[skill] = new Skill(Integer.parseInt(skillEncodedSplit[0]), Integer.parseInt(skillEncodedSplit[1]), Integer.parseInt(skillEncodedSplit[2])); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return skills; } public static Skill getSkill(final String playerName, int skillId) { return getSkills(playerName)[skillId]; } public static Activity[] getActivities(final String playerName) { try { final Activity[] activities = new Activity[ACTIVITY_COUNT]; try (final BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(new StringBuffer(BASE_URL).append(playerName).toString()).openStream()))) { for (int skill = 0; skill < SKILL_COUNT; skill++) { reader.readLine(); } for (int activity = 0; activity < ACTIVITY_COUNT; activity++) { final String[] activityEncodedSplit = reader.readLine().split(","); activities[activity] = new Activity(Integer.parseInt(activityEncodedSplit[0]), Integer.parseInt(activityEncodedSplit[1])); } } return activities; } catch (final IOException e) { throw new IllegalArgumentException("Username not valid"); } } public static Activity getActivity(final String playerName, int activityId) { return getActivities(playerName)[activityId]; } public static class Skill { private final int rank; private final int level; private final int xp; private Skill(final int rank, final int level, final int xp) { this.rank = rank; this.level = level; this.xp = xp; } public int getRank() { return rank; } public int getLevel() { return level; } public int getXp() { return xp; } } public static class Activity { private final int rank; private final int score; private Activity(final int rank, final int score) { this.rank = rank; this.score = score; } public int getRank() { return rank; } public int getScore() { return score; } } } private static enum RawSkill { ATTACK(1), DEFENCE(2), STRENGTH(3), HITPOINTS(4), RANGE(5), PRAYER(6), MAGIC(7), COOKING(8), WOODCUTTING( 9), FLETCHING(10), FISHING(11), FIREMAKING(12), CRAFTING(13), SMITHING(14), MINING(15), HERBLORE( 16), AGILITY(17), THIEVING(18), SLAYER(19), FARMING(20), RUNECRAFTING(21), HUNTER( 22), CONSTRUCTION(23); private final int id; RawSkill(int id) { this.id = id; } private int getID(){ return id; } } Edited June 27, 2016 by LoudPacks 1 Quote Link to comment Share on other sites More sharing options...
progamerz Posted June 27, 2016 Author Share Posted June 27, 2016 (edited) Runescape has an official Highscores API that you can make use of Here is an example of how you could use it: public final Map<String, Stat> getStats(final String playerName) { final Map<String, Stat> stats = new HashMap<>(24); try { URL url = new URL("http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=" + playerName); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); try(InputStreamReader inputStreamReader = new InputStreamReader(con.getInputStream()); BufferedReader br = new BufferedReader(inputStreamReader)) { String[] splitVals = br.readLine().split(","); Stat overallStat = new Stat(Integer.parseInt(splitVals[0]), Integer.parseInt(splitVals[1]), Integer.parseInt(splitVals[2])); stats.put("Overall", overallStat); for (final Skill skill : Skill.values()) { splitVals = br.readLine().split(","); stats.put(skill.toString(), new Stat(Integer.parseInt(splitVals[0]), Integer.parseInt(splitVals[1]), Integer.parseInt(splitVals[2]))); } } } catch(final Exception e){ e.printStackTrace(); } return stats; } Where Stat is: public final class Stat { private final int rank, level, xp; public Stat(final int rank, final int level, final int xp) { this.rank = rank; this.level = level; this.xp = xp; } public final int getRank() { return rank; } public final int getLevel() { return level; } public final int getXp() { return xp; } @Override public final String toString() { return String.format("Rank: %d, Level: %d, XP: %d", rank, level, xp); } } Testing: getStats("zezima").forEach((s, stat) -> System.out.println(s + " " + stat.toString())); Output: Overall Rank: 1044122, Level: 263, XP: 171029 Hunter Rank: 469487, Level: 1, XP: 0 Thieving Rank: 727948, Level: 13, XP: 1872 Construction Rank: 379600, Level: 1, XP: 0 Cooking Rank: 729252, Level: 31, XP: 14890 Magic Rank: 1254581, Level: 2, XP: 110 Fletching Rank: 409758, Level: 37, XP: 27502 Herblore Rank: 619712, Level: 1, XP: 0 Firemaking Rank: 370103, Level: 43, XP: 50460 Attack Rank: 1488162, Level: 7, XP: 652 Fishing Rank: 800753, Level: 24, XP: 7030 Crafting Rank: 961015, Level: 3, XP: 230 Hitpoints Rank: 1623703, Level: 13, XP: 1989 Ranged Rank: -1, Level: 1, XP: 4 Mining Rank: 1002037, Level: 13, XP: 2047 Runecrafting Rank: 511420, Level: 1, XP: 0 Smithing Rank: 1455957, Level: 1, XP: 18 Agility Rank: 829188, Level: 1, XP: 0 Woodcutting Rank: 596579, Level: 44, XP: 61130 Slayer Rank: 786552, Level: 1, XP: 10 Defence Rank: 1391507, Level: 1, XP: 36 Strength Rank: 1382147, Level: 13, XP: 1848 Prayer Rank: 1097298, Level: 10, XP: 1201 Farming Rank: 487599, Level: 1, XP: 0 how can i make it only get the level int for specific skils please help? Coming thru with the DANKS: package com.loudpacks.script.util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; public final class Highscores { public static String username; private Highscores() { } private static final String BASE_URL = "http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player="; private static final int SKILL_COUNT = 24; private static final int ACTIVITY_COUNT = 3; public static Skill[] getSkills(final String playerName) { Skill[] skills = new Skill[SKILL_COUNT]; try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(new StringBuffer(BASE_URL).append(URLEncoder.encode(playerName.replace((char)160, ' '), "UTF-8")).toString()).openStream()))) { for (int skill = 0; skill < SKILL_COUNT; skill++) { String[] skillEncodedSplit = reader.readLine().split(","); skills[skill] = new Skill(Integer.parseInt(skillEncodedSplit[0]), Integer.parseInt(skillEncodedSplit[1]), Integer.parseInt(skillEncodedSplit[2])); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return skills; } public static Skill getSkill(final String playerName, int skillId) { return getSkills(playerName)[skillId]; } public static Activity[] getActivities(final String playerName) { try { final Activity[] activities = new Activity[ACTIVITY_COUNT]; try (final BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(new StringBuffer(BASE_URL).append(playerName).toString()).openStream()))) { for (int skill = 0; skill < SKILL_COUNT; skill++) { reader.readLine(); } for (int activity = 0; activity < ACTIVITY_COUNT; activity++) { final String[] activityEncodedSplit = reader.readLine().split(","); activities[activity] = new Activity(Integer.parseInt(activityEncodedSplit[0]), Integer.parseInt(activityEncodedSplit[1])); } } return activities; } catch (final IOException e) { throw new IllegalArgumentException("Username not valid"); } } public static Activity getActivity(final String playerName, int activityId) { return getActivities(playerName)[activityId]; } public static class Skill { private final int rank; private final int level; private final int xp; private Skill(final int rank, final int level, final int xp) { this.rank = rank; this.level = level; this.xp = xp; } public int getRank() { return rank; } public int getLevel() { return level; } public int getXp() { return xp; } } public static class Activity { private final int rank; private final int score; private Activity(final int rank, final int score) { this.rank = rank; this.score = score; } public int getRank() { return rank; } public int getScore() { return score; } } } Nvm Found it out thanks Edited June 27, 2016 by progamerz Quote Link to comment Share on other sites More sharing options...
Explv Posted June 27, 2016 Share Posted June 27, 2016 (edited) how can i make it only get the level int for specific skils please help? It's a HashMap. You would just do: getStats(playerName).get(Skill.ATTACK.toString()).getLevel(); Coming thru with the DANKS: private static enum RawSkill { ATTACK(1), DEFENCE(2), STRENGTH(3), HITPOINTS(4), RANGE(5), PRAYER(6), MAGIC(7), COOKING(8), WOODCUTTING( 9), FLETCHING(10), FISHING(11), FIREMAKING(12), CRAFTING(13), SMITHING(14), MINING(15), HERBLORE( 16), AGILITY(17), THIEVING(18), SLAYER(19), FARMING(20), RUNECRAFTING(21), HUNTER( 22), CONSTRUCTION(23); private final int id; RawSkill(int id) { this.id = id; } private int getID(){ return id; } } Why wouldn't you just use a HashMap? This seems like a weird solution xD Edited June 27, 2016 by Explv 2 Quote Link to comment Share on other sites More sharing options...
LoudPacks Posted June 28, 2016 Share Posted June 28, 2016 (edited) It's a HashMap. You would just do: getStats(playerName).get(Skill.ATTACK.toString()).getLevel(); Why wouldn't you just use a HashMap? This seems like a weird solution xD I know the skill ids by memory but he skyped me asking about skill ids, this is actually taken from my HeyLookJagex server class for adding skill linked items to the tracker. I just posted it so he would have the real skill ids and not the ones osbot uses which are different from the in game ones. Edited June 28, 2016 by LoudPacks Quote Link to comment Share on other sites More sharing options...