From 31a50c6da7e2f3f95e8c3651d3c47e8500570f3a Mon Sep 17 00:00:00 2001 From: AgentLV Date: Sun, 3 Mar 2024 15:07:52 -0300 Subject: [PATCH] Run sync tasks scheduled for the same tick FIFO --- .../bukkit/craftbukkit/v1_7_R4/scheduler/CraftScheduler.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/v1_7_R4/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/v1_7_R4/scheduler/CraftScheduler.java index 2574a6df..8e764920 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_7_R4/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_7_R4/scheduler/CraftScheduler.java @@ -50,7 +50,10 @@ public class CraftScheduler implements BukkitScheduler { private final PriorityQueue pending = new PriorityQueue(10, new Comparator() { 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(); } }); /**