sudoinit6 Posted October 25, 2017 Share Posted October 25, 2017 Several of my scripts started erroring out and it happens when I use code like this: Spoiler PriceLookup prices = new PriceLookup(); String bucketPrice = prices .getPriceByName("Bucket"); int bucketPriceInt = (Integer.parseInt(bucketPrice)); int bucketBuyPrice = (int) (bucketPriceInt * 1.25); int numBuckets = (int) script.bank.getAmount("Bucket"); int bucketsNeeded = (14 - numBuckets); I use this to determine how much of something to buy obviously. This has worked solidly for months up until yesterday, this morning the bots are standing still and throwing this error: Spoiler [ERROR][Bot #1][10/25 09:40:42 AM]: Error in script executor! java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at BuyBuckets.execute(BuyBuckets.java:43) at JubSapphireRings.onLoop(JubSapphireRings.java:48) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ro:134) at java.lang.Thread.run(Unknown Source) I didn't change anything with the scripts, and the bot didn't change, anyone have any idea what would cause this? Quote Link to comment Share on other sites More sharing options...
Vilius Posted October 25, 2017 Share Posted October 25, 2017 we need code for your pricelookup and it seems that it isnt getting a number back, just an empty string and Integer.parseInt(...) cant parse an empty string. Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted October 25, 2017 Author Share Posted October 25, 2017 PriceLookup.java: Spoiler /** * @author Jacob Smallridge - Polycoding/Polymorphism * Polycoding 2017 http://polycoding.com/ * * Please leave comments & documentation in place. Modify and distribute as you please. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; import java.net.URL; public class PriceLookup { private static final String PRICES_BASE = "http://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item="; private static final String ITEMS_BASE = "http://polycoding.com/osb/itemIdNames.php?getId="; private static final String[][] VALUE_MATRIX = { { "K", "1000" }, { "M", "1000000" }, { "B", "1000000000" }, { "T", "1000000000000" } }; public PriceLookup() { } /** * Retrieves an item's price from Jagex using it's name. * * @param name * @return String representation of price OR empty String on failure */ public String getPriceByName(String name) { try { final String id = getId(name.replace(" ", "%20")); if (id == null || id.trim().isEmpty()) return ""; return parseRS(Integer.valueOf(id)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; } /** * Retrieves an item's price from Jagex using it's in-game ID * * @param id * @return String representation of price OR empty String on failure */ public String getPriceById(int id) { try { final String price = parseRS(id); if (price == null || price.trim().isEmpty()) return ""; return price; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; } /** * Parses the JSON from RuneScape website * * @param itemID * @return itemPrice * @throws IOException */ private String parseRS(final int itemID) throws IOException { final URL url = new URL(PRICES_BASE + itemID); BufferedReader file = new BufferedReader(new InputStreamReader(url.openStream())); String line; String price = null; while ((line = file.readLine()) != null) { if (line.contains("price")) { price = (line).trim(); } } price = price.substring(price.indexOf("current"), price.indexOf("today")).replace("\"", ""); price = price.substring(price.indexOf("price:") + 6, price.lastIndexOf("}")); price = addZeros(price.toUpperCase()); file.close(); return price.replace(",", ""); } /** * Queries Polycoding server to exchange an item's name for it's ID * * @param itemName * Items name * @return Empty string on failure or the raw ID as a String * @throws IOException */ public String getId(String itemName) throws IOException { final URL url = new URL(ITEMS_BASE + itemName); BufferedReader file = new BufferedReader(new InputStreamReader(url.openStream())); String line; String content = null; while ((line = file.readLine()) != null) { content = line.trim(); } file.close(); return content; } /** * Should convert jagex's 15k to 15000 and 15m to 15000000, etc etc * * @param str * @return Unformatted String representation of any number input */ private String addZeros(String str) { for (int i = 0; i < VALUE_MATRIX.length; i++) { if (str.endsWith(VALUE_MATRIX[0])) { BigDecimal temp = new BigDecimal(str.substring(0, str.indexOf(VALUE_MATRIX[0]))); temp = temp.multiply(new BigDecimal(VALUE_MATRIX[1])); str = temp.toBigInteger().toString(); break; } } return str; } } Quote Link to comment Share on other sites More sharing options...
Vilius Posted October 25, 2017 Share Posted October 25, 2017 (edited) Yeah, I wonder why Ofc you are depending on polycoding.com to get item id's then get prices from rs site, but the site is down so you should use a diff method to get the prices. Edited October 25, 2017 by Vilius Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted October 25, 2017 Author Share Posted October 25, 2017 Near as I can tell this site went down: http://polycoding.com/osb/itemIdNames.php?getId=Bucket Which breaks the whole thing. Anyone got a good GE price look up class? Quote Link to comment Share on other sites More sharing options...
Apaec Posted October 25, 2017 Share Posted October 25, 2017 7 minutes ago, sudoinit6 said: PriceLookup.java: Hide contents /** * @author Jacob Smallridge - Polycoding/Polymorphism * Polycoding 2017 http://polycoding.com/ * * Please leave comments & documentation in place. Modify and distribute as you please. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; import java.net.URL; public class PriceLookup { private static final String PRICES_BASE = "http://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item="; private static final String ITEMS_BASE = "http://polycoding.com/osb/itemIdNames.php?getId="; private static final String[][] VALUE_MATRIX = { { "K", "1000" }, { "M", "1000000" }, { "B", "1000000000" }, { "T", "1000000000000" } }; public PriceLookup() { } /** * Retrieves an item's price from Jagex using it's name. * * @param name * @return String representation of price OR empty String on failure */ public String getPriceByName(String name) { try { final String id = getId(name.replace(" ", "%20")); if (id == null || id.trim().isEmpty()) return ""; return parseRS(Integer.valueOf(id)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; } /** * Retrieves an item's price from Jagex using it's in-game ID * * @param id * @return String representation of price OR empty String on failure */ public String getPriceById(int id) { try { final String price = parseRS(id); if (price == null || price.trim().isEmpty()) return ""; return price; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; } /** * Parses the JSON from RuneScape website * * @param itemID * @return itemPrice * @throws IOException */ private String parseRS(final int itemID) throws IOException { final URL url = new URL(PRICES_BASE + itemID); BufferedReader file = new BufferedReader(new InputStreamReader(url.openStream())); String line; String price = null; while ((line = file.readLine()) != null) { if (line.contains("price")) { price = (line).trim(); } } price = price.substring(price.indexOf("current"), price.indexOf("today")).replace("\"", ""); price = price.substring(price.indexOf("price:") + 6, price.lastIndexOf("}")); price = addZeros(price.toUpperCase()); file.close(); return price.replace(",", ""); } /** * Queries Polycoding server to exchange an item's name for it's ID * * @param itemName * Items name * @return Empty string on failure or the raw ID as a String * @throws IOException */ public String getId(String itemName) throws IOException { final URL url = new URL(ITEMS_BASE + itemName); BufferedReader file = new BufferedReader(new InputStreamReader(url.openStream())); String line; String content = null; while ((line = file.readLine()) != null) { content = line.trim(); } file.close(); return content; } /** * Should convert jagex's 15k to 15000 and 15m to 15000000, etc etc * * @param str * @return Unformatted String representation of any number input */ private String addZeros(String str) { for (int i = 0; i < VALUE_MATRIX.length; i++) { if (str.endsWith(VALUE_MATRIX[0])) { BigDecimal temp = new BigDecimal(str.substring(0, str.indexOf(VALUE_MATRIX[0]))); temp = temp.multiply(new BigDecimal(VALUE_MATRIX[1])); str = temp.toBigInteger().toString(); break; } } return str; }} have you checked if the rs website has changed? Quote Link to comment Share on other sites More sharing options...
sudoinit6 Posted October 25, 2017 Author Share Posted October 25, 2017 Thanks all, price checker was broken, implemented Explv's in its place, all is goo. Explv deserves a raise! Quote Link to comment Share on other sites More sharing options...