Log Minecraft Internal Scheduler logs correctly

This commit is contained in:
Aikar 2020-06-28 05:34:23 -04:00
parent c09346c798
commit 900f77fa66
3 changed files with 33 additions and 21 deletions

View file

@ -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()));

View file

@ -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

View file

@ -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());
}