Quickly rewrote this for you, let me know if something isn't clear (derived from your code, it's not how I would do it myself, but this should work ^^)
final int[] worlds = {308, 316, 381, 382, 383, 384, 393, 394};
public int i = 0;
worldHopper.hop(worlds[i]);
new ConditionalSleep(5000) {
@Override
public boolean condition() throws InterruptedException {
return myPlayer().isVisible(); // instead of using isVisible you should probably use the client's login state.
}
}.sleep();
if (i >= worlds.length) {
i = 0;
}
else {
i++;
}