ni562 Posted December 15, 2015 Share Posted December 15, 2015 (edited) Hey i'm trying to get all the bank booths near the player so i can pick a random one..Can anyone one point me in the right direction? I don't want to always be banking the same booth. Edited December 15, 2015 by ni562 Quote Link to comment Share on other sites More sharing options...
Chris Posted December 15, 2015 Share Posted December 15, 2015 if (!getBank().isOpen()) { getBank().open(); new ConditionalSleep(5000) { @Override public boolean condition() { return getBank().isOpen(); } }.sleep(); } Quote Link to comment Share on other sites More sharing options...
Kenn Posted December 15, 2015 Share Posted December 15, 2015 (edited) NPC spot = getNpcs().closest((Filter<NPC>) npc -> npc.getName().equals("Banker") && npc.hasAction("Bank")); Use this for the closest NPC. Always do it by their name and actions because if you use the id of the bank etc, on each RS update, the ids do change so the bot will then be unsuccessful. For a bank booth... if (!getBank().isOpen()) getBank().open(); or try Object bank = getBank().open(); Edited December 15, 2015 by Kenn Quote Link to comment Share on other sites More sharing options...
Nitrousek Posted December 15, 2015 Share Posted December 15, 2015 (edited) public ArrayList<RS2Object> obj() { ArrayList<RS2Object> list = new ArrayList<>(); for (RS2Object o : objects.getAll()) { if (o.getName().equalsIgnoreCase("bank booth")) { list.add(o); } } return list; } Returns what you wanted. From this you can choose a random one. Edited December 15, 2015 by Nitrousek Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted December 15, 2015 Share Posted December 15, 2015 Usually you just want to use bank.open() but to select a booth yourself you could do List<RS2Object> booths = objects.filter(new ContainsNameFilter("bank booth")); RS2Object rndBooth = booths.get(random(0, booths.size()-1)); Quote Link to comment Share on other sites More sharing options...
ni562 Posted December 15, 2015 Author Share Posted December 15, 2015 public ArrayList<RS2Object> obj() { ArrayList<RS2Object> list = new ArrayList<>(); for (RS2Object o : objects.getAll()) { if (o.getName().equalsIgnoreCase("bank booth")) { list.add(o); } } return list; } Returns what you wanted. From this you can choose a random one. Exactly what i needed! thanks for the feedback. I modified it a little and am posting it here if anyone is interested. public RS2Object randomBanker() { ArrayList<RS2Object> list = new ArrayList<>(); RS2Object bank; // Our bank booth for (RS2Object o : objects.getAll()) { if (o.getName().equalsIgnoreCase("Bank booth")) { list.add(o); } } bank = list.get(random(list.size() - 1)); //Chose a random booth return bank; } Quote Link to comment Share on other sites More sharing options...
Explv Posted December 15, 2015 Share Posted December 15, 2015 (edited) Exactly what i needed! thanks for the feedback. I modified it a little and am posting it here if anyone is interested. public RS2Object randomBanker() { ArrayList<RS2Object> list = new ArrayList<>(); RS2Object bank; // Our bank booth for (RS2Object o : objects.getAll()) { if (o.getName().equalsIgnoreCase("Bank booth")) { list.add(o); } } bank = list.get(random(list.size() - 1)); //Chose a random booth return bank; } This is a bit shorter: public RS2Object getRandomBank() { List<RS2Object> banks = getObjects().filter(obj -> obj.getName().equals("Bank booth")); return (banks == null || banks.size() == 0) ? null : banks.get(random(banks.size()-1)); } Edited December 15, 2015 by Explv 1 Quote Link to comment Share on other sites More sharing options...
ni562 Posted December 15, 2015 Author Share Posted December 15, 2015 This is a bit shorter: public RS2Object getRandomBank() { List<RS2Object> banks = getObjects().filter(obj -> obj.getName().equals("Bank booth")); return (banks == null || banks.size() == 0) ? null : banks.get(random(banks.size()-1)); } Thanks man!! Always swooping in and shortening my code :p I'm not sure i understand all of that...you're knowledge of java/programming is greater than mine. Quote Link to comment Share on other sites More sharing options...
Explv Posted December 15, 2015 Share Posted December 15, 2015 (edited) Thanks man!! Always swooping in and shortening my code I'm not sure i understand all of that...you're knowledge of java/programming is greater than mine. It just means: -Get all objects and filter them so that the list only contains objects with the name "Bank booth" -If the list is null, or there are no elements in the list, return null Otherwise return a random value from the list. Edited December 15, 2015 by Explv Quote Link to comment Share on other sites More sharing options...
ni562 Posted December 15, 2015 Author Share Posted December 15, 2015 It just means: -Get all objects and filter them so that the list only contains objects with the name "Bank booth" -If the list is null, or there are no elements in the list, return null Otherwise return a random value from the list. Eclipse is throwing up some warnings..What should i do? Quote Link to comment Share on other sites More sharing options...
Explv Posted December 15, 2015 Share Posted December 15, 2015 Eclipse is throwing up some warnings..What should i do? Ignore them Quote Link to comment Share on other sites More sharing options...
Nitrousek Posted December 16, 2015 Share Posted December 16, 2015 Eclipse is throwing up some warnings..What should i do? Post em here, you need java 8 for the stuff they posted. Ignore them noob ^^ Quote Link to comment Share on other sites More sharing options...
ni562 Posted December 16, 2015 Author Share Posted December 16, 2015 Post em here, you need java 8 for the stuff they posted. noob ^^ "Type Safety: A generic array of Filter<RS2Object> is created for a varargs parameter." anything to worry about? Quote Link to comment Share on other sites More sharing options...
Explv Posted December 16, 2015 Share Posted December 16, 2015 (edited) Post em here, you need java 8 for the stuff they posted. noob ^^ noob?? Learn to Java 8 m8 It is safe to ignore this warning. It is an unchecked generics array creation warning produced by getObjects().filter(). You can just supress it. @SuppressWarnings("unchecked") List<RS2Object> banks = getObjects().filter(obj -> obj.getName().equals("Bank booth")); If you don't want a warning you can always do: List<RS2Object> banks = getObjects().getAll().stream().filter(obj -> obj.getName().equals("Bank booth")).collect(Collectors.toList()); But the first way is perfectly fine and shorter. "Type Safety: A generic array of Filter<RS2Object> is created for a varargs parameter." anything to worry about? No it is not anything to worry about. Edited December 16, 2015 by Explv Quote Link to comment Share on other sites More sharing options...