mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 01:22:54 +00:00
Fix delay with server tasks
This commit is contained in:
parent
f9906c4492
commit
42e6e4c44d
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user