LoudPacks Posted June 19, 2016 Share Posted June 19, 2016 (edited) Area currentBank = closestTo(myPlayer()); private enum Bank { DRAYNOR(Banks.DRAYNOR), AL_KHARID(Banks.AL_KHARID), LUMBRIDGE(Banks.LUMBRIDGE_UPPER), FALADOR_EAST(Banks.FALADOR_EAST), FALADOR_WEST(Banks.FALADOR_WEST), VARROCK_EAST(Banks.FALADOR_EAST), VARROCK_WEST(Banks.VARROCK_WEST), SEERS(Banks.CAMELOT), CATHERBY(Banks.CATHERBY), EDGEVILLE(Banks.EDGEVILLE), YANILLE(Banks.YANILLE), GNOME_STRONGHOLD(Banks.GNOME_STRONGHOLD), ARDOUNGE_NORTH(Banks.ARDOUGNE_NORTH), ARDOUNE_SOUTH(Banks.ARDOUGNE_SOUTH), CASTLE_WARS(Banks.CASTLE_WARS), DUEL_ARENA(Banks.DUEL_ARENA), PEST_CONTROL(Banks.PEST_CONTROL), CANIFIS(Banks.CANIFIS), BLAST_FURNACE(new Area(1949, 4956, 1947, 4958)), TZHAAR(Banks.TZHAAR); private final Area area; Bank(Area area) { this.area = area; } } public static Area closestTo(Entity e) { HashMap<Bank, Integer> distMap = new HashMap<Bank, Integer>(); for (Bank b : Bank.values()) { distMap.put(b, e.getPosition().distance(b.area.getRandomPosition())); } HashMap<Integer, Bank> distMapSorted = sortByDistance(distMap); Area cBank = distMapSorted.values().toArray(new Bank[Bank.values().length])[0].area; return cBank; } private static <K, V extends Comparable<? super V>> HashMap<V, K> sortByDistance(Map<K, V> map) { HashMap<V, K> result = new LinkedHashMap<>(); Stream<Map.Entry<K, V>> st = map.entrySet().stream(); st.sorted(Map.Entry.comparingByValue()).forEachOrdered(e -> result.put(e.getValue(), e.getKey())); return result; } Edited June 20, 2016 by LoudPacks 5 Quote Link to comment Share on other sites More sharing options...
Muffins Posted June 20, 2016 Share Posted June 20, 2016 noice, thanks! Quote Link to comment Share on other sites More sharing options...
Extreme Scripts Posted June 20, 2016 Share Posted June 20, 2016 Just to add a point, Gnome stronghold bank has an incorrect area plane, so just watch out for that 1 Quote Link to comment Share on other sites More sharing options...
AresScripts Posted June 20, 2016 Share Posted June 20, 2016 Just to add a point, Gnome stronghold bank has an incorrect area plane, so just watch out for that thats not adding a point, wouldnt that be changing a point Quote Link to comment Share on other sites More sharing options...
Alek Posted June 20, 2016 Share Posted June 20, 2016 Just to add a point, Gnome stronghold bank has an incorrect area plane, so just watch out for that Incorrect, the plane is set to "1". 1 Quote Link to comment Share on other sites More sharing options...
Extreme Scripts Posted June 20, 2016 Share Posted June 20, 2016 Incorrect, the plane is set to "1". When tryign to walk with webwalkevent it doesn't climb the stairs, assumed teh plane was still at 0. thats not adding a point, wouldnt that be changing a point I meant adding a point to the overall spectrum, not to the post Quote Link to comment Share on other sites More sharing options...
AresScripts Posted June 20, 2016 Share Posted June 20, 2016 (edited) Incorrect, the plane is set to "1". When tryign to walk with webwalkevent it doesn't climb the stairs, assumed teh plane was still at 0. I meant adding a point to the overall spectrum, not to the post Im almost 100% positive it does work. Ive been using my slayer today and it worked when I had it bank there. Edited June 20, 2016 by AresScripts Quote Link to comment Share on other sites More sharing options...
Harry Posted June 20, 2016 Share Posted June 20, 2016 Very nice, thanks dude. Quote Link to comment Share on other sites More sharing options...
Extreme Scripts Posted June 20, 2016 Share Posted June 20, 2016 Im almost 100% positive it does work. Ive been using my slayer today and it worked when I had it bank there. This was a couple versions ago not sure about now, could be :P 1 Quote Link to comment Share on other sites More sharing options...
TheGreatests Posted October 1, 2016 Share Posted October 1, 2016 Can you also add the imports. I keep getting issues, such as e needing to be a variable. Quote Link to comment Share on other sites More sharing options...
CLoud Posted July 24, 2018 Share Posted July 24, 2018 On 6/19/2016 at 5:56 PM, LoudPacks said: VARROCK_EAST(Banks.FALADOR_EAST), Referring to OP's work it looks like VARROCK_EAST is assigned to FALADOR_EAST instead of VARROCK_EAST. Just a heads up 1 Quote Link to comment Share on other sites More sharing options...