I would recommend learning the basics of Java (and programming) in general before attempting to write a script.
//pseucode for what i was talking about below
List worldList = [301,302,303,304,305,306,307,308,309]
int x = 0; //zero is beginning of an array
if wantToWorldhop(){
worlds.hop(worldList[x]);
x++; //x is now 1, x will not hop to 302 next time of calling worlds.hop(worldlist[x])
}