From 75e292b1b8c8e73ea4f12104d7f52e6656f128fa Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 3 Aug 2023 23:32:29 +0200 Subject: [PATCH] Fixing big mistake in SchedulerUtil.runOnServerThread(). Provided Runnable was run twice if the method was called from Server Thread. --- .../java/fr/pandacube/lib/paper/scheduler/SchedulerUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/SchedulerUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/SchedulerUtil.java index 36b4291..6ecf4fb 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/SchedulerUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/scheduler/SchedulerUtil.java @@ -20,8 +20,10 @@ public class SchedulerUtil { * @param task the task to run on the main thread. */ public static void runOnServerThread(Runnable task) { - if (Bukkit.isPrimaryThread()) + if (Bukkit.isPrimaryThread()) { task.run(); + return; + } Bukkit.getScheduler().runTask(PandaLibPaper.getPlugin(), task); }