Fix delay with server tasks

This commit is contained in:
KingRainbow44 2023-01-08 14:00:00 +01:00
parent f9906c4492
commit 42e6e4c44d
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -38,9 +38,14 @@ public final class ServerTask implements Runnable {
// Increase tick count. // Increase tick count.
var ticks = this.ticks++; var ticks = this.ticks++;
if (this.delay != -1 && this.considerDelay) { if (this.delay != -1 && this.considerDelay) {
this.considerDelay = false; // Check if the task should run.
return ticks == this.delay; var shouldRun = ticks >= this.delay;
} else if (this.period != -1) return ticks % this.period == 0; // Check if the task should be canceled.
if (shouldRun) this.considerDelay = false;
return shouldRun; // Return the result.
} else if (this.period != -1)
return ticks % this.period == 0;
else return true; else return true;
} }