Bobbey Posted January 24, 2019 Posted January 24, 2019 (edited) Here is a quick bad fix to keep your farms running. The world hopper is broken: private static final int[] F2PWORLDS = new int[] { 335, 379, 380, 382, 383, 384, 393, 394, 397, 398, 399, 418, 430, 431, 433, 434, 435, 436, 437, 438, 439, 440, 451, 452, 453, 454, 455, 456, 457, 458, 459, 497, 498, 499, 500, 501, 502, 503, 504 }; private RS2Widget wor; public void hop(int world) { safeWhile(() -> !getLogoutTab().isOpen() && !getWorlds().isOpen(), 10, new Runnable() { public void run() { getLogoutTab().open(); s(1000, 2000); } }); safeWhile(() -> !getWorlds().isOpen(), 10, new Runnable() { public void run() { getWidgets().get(182, 4).interact("World Switcher"); s(1000, 2000); } }); Random r = new Random(); s(1000, 2000); updateWor(world); getWidgets().get(69, 8).hover(); safeWhile(() -> (wor.getAbsY() > 430 || wor.getAbsY() < 240), 40, new Runnable() { @Override public void run() { updateWor(world); getWidgets().get(69, 8).hover(); if (wor.getAbsY() > 430) { getMouse().scrollDown(); s(80 + r.nextInt(5)); getMouse().scrollDown(); s(80 + r.nextInt(5)); getMouse().scrollDown(); } else { getMouse().scrollUp(); s(80 + r.nextInt(5)); getMouse().scrollUp(); s(80 + r.nextInt(5)); getMouse().scrollUp(); } s(100 + r.nextInt(20)); } }); if (wor.hover()) { // getMouse().click(false); wor.interact("Switch"); } s(5000); } public void hopF2P() { Random r = new Random(); int world = F2PWORLDS[r.nextInt(F2PWORLDS.length)]; hop(world); } private void updateWor(int world) { wor = getWidgets().get(69, 16, world); } update: you need to click the dialogue to actually hop: something like this waitUntil(() -> getDialogues().isPendingOption(), 500, 10); safeWhile(() -> getDialogues().isPendingOption(), 10, new Runnable() { @Override public void run() { try { getDialogues().completeDialogue("Yes."); } catch (InterruptedException e) { e.printStackTrace(); } s(500); } }); And how could I forget: public void safeWhile(Condition c, int attempts, Runnable runnable) { while (getBot().getScriptExecutor().isRunning() && !getBot().getScriptExecutor().isPaused() && !getBot().getScriptExecutor().isSuspended() && c.evaluate()) { if (attempts-- == 0) return; runnable.run(); } } public boolean waitUntil(Condition c, int interval, int tries) { safeWhile(() -> !c.evaluate(), tries, new Runnable() { @Override public void run() { try { sleep(interval); } catch (InterruptedException e) { e.printStackTrace(); } } }); return true; } public interface Condition { boolean evaluate(); } Edited January 24, 2019 by Bobbey 1
Developer Patrick Posted January 24, 2019 Developer Posted January 24, 2019 Something changed on how we detect the worlds, next release will have it fixed. 1