From 900f77fa664675ad4bb02b270ca844ab16d7aaf5 Mon Sep 17 00:00:00 2001 From: Aikar <aikar@aikar.co> Date: Sun, 28 Jun 2020 05:34:23 -0400 Subject: [PATCH] Log Minecraft Internal Scheduler logs correctly --- .../Add-exception-reporting-event.patch | 24 ++++------------- Spigot-Server-Patches/MC-Utils.patch | 26 +++++++++++++++++++ Spigot-Server-Patches/Timings-v2.patch | 4 +-- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/Spigot-Server-Patches/Add-exception-reporting-event.patch b/Spigot-Server-Patches/Add-exception-reporting-event.patch index c94eaf0751..f0f892dad9 100644 --- a/Spigot-Server-Patches/Add-exception-reporting-event.patch +++ b/Spigot-Server-Patches/Add-exception-reporting-event.patch @@ -267,29 +267,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.bukkit.plugin.IllegalPluginAccessException; import org.bukkit.plugin.Plugin; @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { - try { - task.run(); - } catch (final Throwable throwable) { -+ // Paper start -+ String msg = String.format( -+ "Task #%s for %s generated an exception", -+ task.getTaskId(), -+ task.getOwner().getDescription().getFullName()); - task.getOwner().getLogger().log( - Level.WARNING, -- String.format( -- "Task #%s for %s generated an exception", -- task.getTaskId(), -- task.getOwner().getDescription().getFullName()), -+ msg, + msg, throwable); + } + task.getOwner().getServer().getPluginManager().callEvent( -+ new ServerExceptionEvent(new ServerSchedulerException(msg, throwable, task)) -+ ); -+ // Paper end ++ new ServerExceptionEvent(new ServerSchedulerException(msg, throwable, task))); + // Paper end } finally { currentTask = null; - } +@@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { parsePending(); } else { debugTail = debugTail.setNext(new CraftAsyncDebugger(currentTick + RECENT_TICKS, task.getOwner(), task.getTaskClass())); diff --git a/Spigot-Server-Patches/MC-Utils.patch b/Spigot-Server-Patches/MC-Utils.patch index f17ed02a0d..d84ff986fc 100644 --- a/Spigot-Server-Patches/MC-Utils.patch +++ b/Spigot-Server-Patches/MC-Utils.patch @@ -4494,6 +4494,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public BukkitTask runTaskTimer(Plugin plugin, Object runnable, long delay, long period) { validate(plugin, runnable); if (delay < 0L) { +@@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { + task.run(); + task.timings.stopTiming(); // Spigot + } catch (final Throwable throwable) { +- task.getOwner().getLogger().log( ++ // Paper start ++ String msg = String.format( ++ "Task #%s for %s generated an exception", ++ task.getTaskId(), ++ task.getOwner().getDescription().getFullName()); ++ if (task.getOwner() == MINECRAFT) { ++ net.minecraft.server.MinecraftServer.LOGGER.error(msg, throwable); ++ } else { ++ task.getOwner().getLogger().log( + Level.WARNING, +- String.format( +- "Task #%s for %s generated an exception", +- task.getTaskId(), +- task.getOwner().getDescription().getFullName()), ++ msg, + throwable); ++ } ++ // Paper end + } finally { + currentTask = null; + } diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java diff --git a/Spigot-Server-Patches/Timings-v2.patch b/Spigot-Server-Patches/Timings-v2.patch index 4a894b8f4b..eff3a693e5 100644 --- a/Spigot-Server-Patches/Timings-v2.patch +++ b/Spigot-Server-Patches/Timings-v2.patch @@ -2028,8 +2028,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 task.run(); - task.timings.stopTiming(); // Spigot } catch (final Throwable throwable) { - task.getOwner().getLogger().log( - Level.WARNING, + // Paper start + String msg = String.format( @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { runners.remove(task.getTaskId()); }