From 807b7ce4ed2894a16e5052d6ca943aac8463c847 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 4 Jul 2021 18:20:33 +0200 Subject: [PATCH] =?UTF-8?q?Trying=20improve=20logs=20in=20lib=20paper?= =?UTF-8?q?=E2=80=99s=20ThreadUtil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/pandacube/lib/paper/util/ThreadUtil.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Paper/src/main/java/fr/pandacube/lib/paper/util/ThreadUtil.java b/Paper/src/main/java/fr/pandacube/lib/paper/util/ThreadUtil.java index 780429f..e58aff8 100644 --- a/Paper/src/main/java/fr/pandacube/lib/paper/util/ThreadUtil.java +++ b/Paper/src/main/java/fr/pandacube/lib/paper/util/ThreadUtil.java @@ -1,7 +1,6 @@ package fr.pandacube.lib.paper.util; import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; import org.bukkit.Bukkit; @@ -21,13 +20,14 @@ public class ThreadUtil { if (Bukkit.isPrimaryThread()) return task.call(); - try { - return Bukkit.getScheduler().callSyncMethod(PandaLibPaper.getPlugin(), task).get(); - } catch (ExecutionException e) { - Log.severe("Execution Exception while running code on server Thread. The source exception is:", - e.getCause()); - throw e; - } + return Bukkit.getScheduler().callSyncMethod(PandaLibPaper.getPlugin(), () -> { + try { + return task.call(); + } catch (Exception e) { + Log.severe("Exception while running callback code on server Thread. The source exception is:", e); + throw e; + } + }).get(); } public static void runOnServerThreadAndWait(Runnable task) throws Exception {