From 1c7f64595ed1bd171e46fa35f9c43de1fa7bb803 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 4 Jul 2021 16:05:45 +0200 Subject: [PATCH] Fix some log stuff --- .../core/network_api/server/NetworkAPIListener.java | 6 ++++-- .../java/fr/pandacube/lib/paper/util/ThreadUtil.java | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/fr/pandacube/lib/core/network_api/server/NetworkAPIListener.java b/Core/src/main/java/fr/pandacube/lib/core/network_api/server/NetworkAPIListener.java index dc4f821..e391901 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/network_api/server/NetworkAPIListener.java +++ b/Core/src/main/java/fr/pandacube/lib/core/network_api/server/NetworkAPIListener.java @@ -5,6 +5,8 @@ import java.net.ServerSocket; import java.util.Arrays; import java.util.HashMap; +import fr.pandacube.lib.core.util.Log; + @Deprecated public class NetworkAPIListener implements Runnable { @@ -40,7 +42,7 @@ public class NetworkAPIListener implements Runnable { } } - System.out.println("NetworkAPI '" + name + "' à l'écoute sur le port " + port); + Log.info("NetworkAPI '" + name + "' à l'écoute sur le port " + port); try { // réception des connexion client @@ -57,7 +59,7 @@ public class NetworkAPIListener implements Runnable { } catch (IOException e) {} } - System.out.println("NetworkAPI '" + name + "' ferme le port " + port); + Log.info("NetworkAPI '" + name + "' ferme le port " + port); } 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 27a46d1..780429f 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,9 +1,11 @@ package fr.pandacube.lib.paper.util; import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; import org.bukkit.Bukkit; +import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.paper.PandaLibPaper; public class ThreadUtil { @@ -19,7 +21,13 @@ public class ThreadUtil { if (Bukkit.isPrimaryThread()) return task.call(); - return Bukkit.getScheduler().callSyncMethod(PandaLibPaper.getPlugin(), task).get(); + 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; + } } public static void runOnServerThreadAndWait(Runnable task) throws Exception {