There is a way that you could do this without setting 24 separate timers. You could create one, with the time interval being 1
. Then, you could add one to a number every time the timer runs. Like this:
int loops;
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
public void run() {
loops++;//add one to the loops
}
},1, 1);
Then, for every time interval, you could set up a check to see if loops
is divisible by the interval... For example, let's say that you would like to have a fly check
every 5 ticks, and your withdraw
timer every 7 ticks. You could do this:
int loops;
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
public void run() {
loops++;//add one to the loops
if(loops % 5 == 0){//if loops is divisible by 5
//fly check code
}
if(loops % 7 == 0){//if loops is divisible by 7
//withdraw code
}
}
},1, 1); //make the timer repeat every 1 tick
Just make sure that you only use if
statements, not else if
. If you use else if
above, and loops is 35, which is divisible by 5 and 7, it will run the first statement, but not the second, because you are telling it to run that statement only if the above ones are false. Therefor, if you only use if
statements, then it will be able to check every single one of them, and multiple will be able to be called.