Trying improve logs in lib paper’s ThreadUtil
This commit is contained in:
parent
04148b88b3
commit
807b7ce4ed
@ -1,7 +1,6 @@
|
|||||||
package fr.pandacube.lib.paper.util;
|
package fr.pandacube.lib.paper.util;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
@ -21,13 +20,14 @@ public class ThreadUtil {
|
|||||||
if (Bukkit.isPrimaryThread())
|
if (Bukkit.isPrimaryThread())
|
||||||
return task.call();
|
return task.call();
|
||||||
|
|
||||||
try {
|
return Bukkit.getScheduler().callSyncMethod(PandaLibPaper.getPlugin(), () -> {
|
||||||
return Bukkit.getScheduler().callSyncMethod(PandaLibPaper.getPlugin(), task).get();
|
try {
|
||||||
} catch (ExecutionException e) {
|
return task.call();
|
||||||
Log.severe("Execution Exception while running code on server Thread. The source exception is:",
|
} catch (Exception e) {
|
||||||
e.getCause());
|
Log.severe("Exception while running callback code on server Thread. The source exception is:", e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
}).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runOnServerThreadAndWait(Runnable task) throws Exception {
|
public static void runOnServerThreadAndWait(Runnable task) throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user