diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 9d30b79ceb..6365b382d2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -260,4 +260,8 @@ public final class CraftServer implements Server { pluginManager.callEvent(new WorldEvent(Type.WORLD_LOADED, world)); } + + public Logger getLogger() { + return MinecraftServer.a; + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/LoggerOutputStream.java b/paper-server/src/main/java/org/bukkit/craftbukkit/LoggerOutputStream.java new file mode 100644 index 0000000000..d2637ad8e1 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/LoggerOutputStream.java @@ -0,0 +1,32 @@ + +package org.bukkit.craftbukkit; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class LoggerOutputStream extends ByteArrayOutputStream { + private final String separator = System.getProperty("line.separator"); + private final Logger logger; + private final Level level; + + public LoggerOutputStream(Logger logger, Level level) { + super(); + this.logger = logger; + this.level = level; + } + + @Override + public void flush() throws IOException { + synchronized (this) { + super.flush(); + String record = this.toString(); + super.reset(); + + if ((record.length() > 0) && (!record.equals(separator))) { + logger.logp(level, "", "", record); + } + } + } +}