Instead of using rs GE, use rsbuddy GE as its more reflective of actual prices imo...
Following code was found elsewhere and adopted for my usecase (sorry cant remember source)
private final static String RSBUDDY_URL = "https://rsbuddy.com/exchange/summary.json";
public static HashMap<String, Integer> getPriceMap(List<String> items) {
HashMap<String, Integer> priceMap = new HashMap<>();
try {
URL url = new URL(RSBUDDY_URL);
BufferedReader jsonFile = new BufferedReader(new InputStreamReader(url.openStream()));
JsonObject priceJSON = JsonObject.readFrom(jsonFile.readLine());
Iterator<Member> iterator = priceJSON.iterator();
while (iterator.hasNext()) {
JsonObject itemJSON = priceJSON.get(iterator.next().getName()).asObject();
String itemName = itemJSON.get("name").asString();
if (items.contains(itemName)) {
priceMap.put(itemName, itemJSON.get("buy_average").asInt());
}
}
} catch (Exception e) {
}
return priceMap;
}
Then, every time you loot an item or if you already know the item name, add it to a list of strings. You can use it as such....
HashMap<String,Integer> itemPrices = new HashMap();
itemPrices = getPriceMap(items);
For keeping a list of total looted you could (inefficiently, sorry unwilling to share my code)
for(String item : items){
itemPrices = getPriceMap(items);
try {
total = total + itemPrices.get(item);
}
catch (Exception e) {
log("Empty");
}
}
items.clear();
}
You can use the following library (literally just copy and paste the .java files into your code, I don't know of a better way of doing this)
https://github.com/ralfstx/minimal-json