Soldtodie Posted May 23, 2015 Posted May 23, 2015 public class worldSwitcher { public static final int WIDGET_PARENT = 69; public static final int WIDGET_INTERFACE_CHILD = 4; public static final int WIDGET_CLOSE_CHILD = 3; public static final int WIDGET_SWITCHER_BUTTON_PARENT = 182; public static final int WIDGET_SWITCHER_BUTTON_CHILD = 5; //Worlds public static final int WIDGET_WORLD_CHILD_START = 13; public static final int WIDGET_WORLD_CHILD_END = 82; public static final int WIDGET_WORLD_GRANDCHILD_SPRITE = 1; public static final int WIDGET_WORLD_GRANDCHILD_NUMBER = 2; public static final int WIDGET_WORLD_GRANDCHILD_FLAG = 3; public static final int WIDGET_WORLD_GRANDCHILD_NAME = 4; public static final int FREE_SPRITE = 1130; public static final int MEMBER_SPRITE = 1131; public static final int GERMANY_FLAG_SPRITE = 1140; public static final int AMERICA_FLAG_SPRITE = 1133; public static final int BRITAIN_FLAG_SPRITE = 1135; //Favourite worlds public static final int WIDGET_FAVOURITE_WORLD_CHILD_START = 114; public static final int WIDGET_FAVOURITE_WORLD_CHILD_END = 115; //Sort buttons public static final int WIDGET_SORT_MEMBER_BUTTON_CHILD = 9; public static final int WIDGET_SORT_WORLD_BUTTON_CHILD = 10; public static final int WIDGET_SORT_FLAG_BUTTON_CHILD = 11; public static final int WIDGET_SORT_NAME_BUTTON_CHILD = 12; public static final int WIDGET_SORT_BUTTON_GRANDCHILD_SPRITE = 0; public static final int WIDGET_SORT_BUTTON_GRANDCHILD_ALPHA = 0; public static final int ALPHA_ON = 0; public static final int ALPHA_OFF = 100; public static final int UP_SPRITE = 1050; public static final int DOWN_SPRITE = 1051; //Scroll buttons public static final int WIDGET_SCROLL_BUTTON_CHILD = 113; public static final int WIDGET_SCROLL_BUTTON_UP_GRANDCHILD = 4; public static final int WIDGET_SCROLL_BUTTON_DOWN_GRANDCHILD = 5; public boolean isOpen() { RS2Widget iFace = getWidgets().get(WIDGET_PARENT, WIDGET_INTERFACE_CHILD); if(iFace != null) { if(iFace.getPosition().x != -1 && iFace.getPosition().y != -1) { return true; } } return false; } public boolean open() throws InterruptedException { if(!isOpen()) { if(getTabs().open(Tab.LOGOUT)) { Script.sleep(Script.random(150, 350)); RS2Widget button = getWidgets().get(WIDGET_SWITCHER_BUTTON_PARENT, WIDGET_SWITCHER_BUTTON_CHILD); if(button != null) { if(button.interact("World Switcher")) { Script.sleep(Script.random(1000, 1350)); return isOpen(); } } else { Script.sleep(Script.random(350, 650)); return isOpen(); } } } else { return true; } return false; } public boolean close() { if(isOpen()) { RS2Widget button = getWidgets().get(WIDGET_PARENT, WIDGET_CLOSE_CHILD); if(button != null) { return getMouse().click(new RectangleDestination(getBot(), new Rectangle(button.getPosition().x, button.getPosition().y, 22, 22))); } } return false; } public RS2Widget getWorld(int world) throws InterruptedException { if(isOpen()) { for(int worldIndex = WIDGET_WORLD_CHILD_START; worldIndex <= WIDGET_WORLD_CHILD_END; worldIndex++) { RS2Widget widgetWorld = getWidgets().get(WIDGET_PARENT, worldIndex); if(widgets != null) { RS2Widget childWorld = widgetWorld.getChildWidget(WIDGET_WORLD_GRANDCHILD_NUMBER); if(childWorld != null) { int worldNumber = Integer.parseInt(childWorld.getMessage()); if(worldNumber == world) { return widgetWorld; } } } } } return null; } public boolean isVisible(int world) throws InterruptedException { RS2Widget widgetWorld = getWorld(world); return isVisible(widgetWorld); } public boolean isVisible(RS2Widget widget) throws InterruptedException { if(widget != null) { RS2Widget iFace = getWidgets().get(WIDGET_PARENT, WIDGET_INTERFACE_CHILD); if(iFace != null) { if(iFace.getRectangle().contains(widget.getRectangle())) { return true; } } } return false; } public boolean scrollToTop() throws InterruptedException { RS2Widget button = getWidgets().get(WIDGET_PARENT, WIDGET_SORT_MEMBER_BUTTON_CHILD); if(button != null) { return scrollTo(button); } return false; } public boolean scrollTo(final int world) throws InterruptedException { if(isVisible(world)) { return true; } RS2Widget widgetWorld = getWorld(world); if(widgetWorld != null) { return scrollTo(widgetWorld); } return false; } public boolean scrollTo(final RS2Widget widgetWorld) throws InterruptedException { if(isVisible(widgetWorld)) { return true; } RS2Widget iFace = getWidgets().get(WIDGET_PARENT, WIDGET_INTERFACE_CHILD); if(iFace != null) { if(widgetWorld.getPosition().y > iFace.getPosition().y) { RS2Widget buttonDown = getWidgets().get(WIDGET_PARENT, WIDGET_SCROLL_BUTTON_CHILD, WIDGET_SCROLL_BUTTON_DOWN_GRANDCHILD); if(buttonDown != null) { getMouse().continualClick(new RectangleDestination(getBot(), buttonDown.getRectangle()), new Condition() { @Override public boolean evaluate() { try { if(isVisible(widgetWorld)) { Script.sleep(Script.random(0, 880)); return true; } else { return false; } } catch (InterruptedException e) { e.printStackTrace(); } return true; } }); } } else { RS2Widget buttonUp = getWidgets().get(WIDGET_PARENT, WIDGET_SCROLL_BUTTON_CHILD, WIDGET_SCROLL_BUTTON_UP_GRANDCHILD); if(buttonUp != null) { getMouse().continualClick(new RectangleDestination(getBot(), buttonUp.getRectangle()), new Condition() { @Override public boolean evaluate() { try { if(isVisible(widgetWorld)) { Script.sleep(Script.random(0, 880)); return true; } else { return false; } } catch (InterruptedException e) { e.printStackTrace(); } return true; } }); } } } return isVisible(widgetWorld); } public boolean switchWorld(int world) throws InterruptedException { String sWorld = ""+getClient().getCurrentWorld(); sWorld = sWorld.replaceFirst("3", "0"); int currentWorld = Integer.parseInt(sWorld); if(currentWorld == world) { return true; } if(open()) { RS2Widget widgetWorld = getWorld(world); if(widgetWorld != null && scrollTo(world)) { if(widgetWorld.interact("Switch")) { Script.sleep(Script.random(500, 850)); return getDialogues().completeDialogue("Yes."); } } } return false; } } I don't added every function for the switcher but I added every information for you to add other functions. How to use: worldSwitcher switcher = new worldSwitcher(); switcher.switchWorld(83); 3