Fay Posted March 28, 2014 Share Posted March 28, 2014 (edited) Could probably be done better but I don't think there is a built-in function to find it nor did I see any PC bots utilizing it. (Yes this was originally made for automatic world hopping in PC.) The Code for mode() was found here: http://deveshsharma.info/2013/07/16/find-most-common-element-in-a-list-in-java/ ^ because I didn't want to make it. import java.awt.Graphics; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.osbot.script.Script; import org.osbot.script.ScriptManifest; import org.osbot.script.rs2.ui.RS2InterfaceChild; import org.osbot.script.rs2.ui.Tab; private static int mode(List < Integer > list) { Map < Integer, Integer > map = new HashMap < Integer, Integer > (); for (int i = 0; i < list.size(); i++) { Integer frequency = map.get(list.get(i)); if (frequency == null) { map.put(list.get(i), 1); } else { map.put(list.get(i), frequency + 1); } } int mostCommonKey = -1; int maxValue = -1; for (Map.Entry < Integer, Integer > entry: map.entrySet()) { if (entry.getValue() > maxValue) { mostCommonKey = entry.getKey(); maxValue = entry.getValue(); } } return mostCommonKey; } public int chatWorld() throws InterruptedException { openTab(Tab.CLANCHAT); List < Integer > chatWorlds = new ArrayList < Integer > (); int hopWorld = -1; RS2InterfaceChild chatbox = client.getInterface(589).getChild(5); RS2InterfaceChild[] people = chatbox.getChildren(); for (RS2InterfaceChild world: people) { if (world.getMessage().contains("World ")) { chatWorlds.add(Integer.parseInt(world.getMessage().replace("World ", ""))); } } hopWorld = mode(chatWorlds); return hopWorld; } Edited March 28, 2014 by Fay 1 Link to comment Share on other sites More sharing options...
Swizzbeat Posted March 28, 2014 Share Posted March 28, 2014 The one I developed for my PC script is shorter ;) Link to comment Share on other sites More sharing options...
Fay Posted March 28, 2014 Author Share Posted March 28, 2014 (edited) Lol, I'd believe it. But then again you didn't release it (the source I mean). Edited March 28, 2014 by Fay Link to comment Share on other sites More sharing options...
andzelmaz Posted March 29, 2014 Share Posted March 29, 2014 short enough, looks good though Link to comment Share on other sites More sharing options...
lazyy Posted April 12, 2014 Share Posted April 12, 2014 (edited) is this the correct way of using it public void hop() throws Exception{ if(client.getCurrentWorld() != mostCommonKey){ this.worldHopper.hopWorld(mostCommonKey); } } please help Edited April 12, 2014 by lazyy Link to comment Share on other sites More sharing options...