Skip to content

Commit

Permalink
Run sync tasks scheduled for the same tick FIFO
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentLV authored and juanmuscaria committed Mar 3, 2024
1 parent b4277c7 commit 31a50c6
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public class CraftScheduler implements BukkitScheduler {
private final PriorityQueue<CraftTask> pending = new PriorityQueue<CraftTask>(10,
new Comparator<CraftTask>() {
public int compare(final CraftTask o1, final CraftTask o2) {
return (int) (o1.getNextRun() - o2.getNextRun());
int value = (int) (o1.getNextRun() - o2.getNextRun());

// If the tasks should run on the same tick they should be run FIFO
return value != 0 ? value : o1.getTaskId() - o2.getTaskId();
}
});
/**
Expand Down

0 comments on commit 31a50c6

Please sign in to comment.