cattycatcat Posted August 20, 2016 Share Posted August 20, 2016 (edited) Hello so i have problem with worldhopping (I'm not good at conditional sleep so please help me to solve it ) if(store.isOpen()) { Item test1 = getStore().getItem("Item"); if (test1 != null && getStore().getAmount("Item") > 0) { getStore().buy("Item", 5); } } Item test2 = getStore().getItem("Item2"); if (test2 != null && getStore().getAmount("Item2") > 0) { getStore().buy("Item2", 5); } if (getStore().isOpen()) { getStore().close(); new ConditionalSleep(5500, 6000) { public boolean condition() throws InterruptedException { return !getStore().isOpen(); } }.sleep(); getWorlds().hopToP2PWorld(); new ConditionalSleep(15000, 25000) { public boolean condition() throws InterruptedException { return myPlayer().exists(); } }.sleep(); } } } The problem is after world hop it starts to eat all my cpu.So if sombody could help me that would be great Edited August 20, 2016 by cattycatcat Quote Link to comment Share on other sites More sharing options...
btsfan Posted August 20, 2016 Share Posted August 20, 2016 (edited) myPlayer() might be null, try checking if it's not null in the ConditionalSleep Also, you can define the amount of time the ConditionalSleep loop waits between each iteration like so: (2nd parameter of the constructor) new ConditionalSleep(random(15000, 25000), random(300,800)) { public boolean condition() throws InterruptedException { return condition; } }.sleep(); Edited August 20, 2016 by btsfan Quote Link to comment Share on other sites More sharing options...
cattycatcat Posted August 20, 2016 Author Share Posted August 20, 2016 Thanks will try Quote Link to comment Share on other sites More sharing options...
Solzhenitsyn Posted August 20, 2016 Share Posted August 20, 2016 The most reliable way I found was to sleep until the current world has changed. I posted a snippet in the scripting subforum which might save you some time. Quote Link to comment Share on other sites More sharing options...
House Posted August 20, 2016 Share Posted August 20, 2016 (edited) Untested: boolean hop = false; int oldWorld = -1; if (hop) { if (getStore().isOpen()) { getStore().close(); return 300; } getWorlds().hopToP2PWorld(); if (oldWorld != getWorlds().getCurrentWorld()) hop = false; return 300; } if (!getStore().isOpen()) { // open store return 300; } String item1Name = "Item1"; String item2Name = "Item2"; Item item1 = getStore().getItem(item1Name); Item item2 = getStore().getItem(item2Name); if (item1 != null && getStore().getAmount(item1Name) > 0) { getStore().buy(item1Name, 5); return 300; } if (item2 != null && getStore().getAmount(item2Name) > 0) { getStore().buy(item2Name, 5); return 300; } hop = true; oldWorld = getWorlds().getCurrentWorld(); Hope you get the gist of it Also use HHopper Edited August 20, 2016 by House Quote Link to comment Share on other sites More sharing options...