Files
Purpur/patches/server/0202-Redirect-System.out-calls-to-plugin-loggers.patch
Encode42 26e5f080f2 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@b4192fd fix NPE from changes in e4358b82171
PaperMC/Paper@5b6445a Revert "fix NPE from changes in e4358b82171"
PaperMC/Paper@323c087 Revert "#686: Fix contains for default section generating real sections"
PaperMC/Paper@c837002 Fix client world difficulty sync issue (#7035)
PaperMC/Paper@a4782f7 [ci skip] fixup indent
PaperMC/Paper@83aee0f [ci skip] Clarify setSize consequences for Slimes (#7036)
PaperMC/Paper@7c8fdc1 Add dropped hunk from mid-tick tasks (#7034)
PaperMC/Paper@fd263ef Fix empty/null chunk section check in LevelChunk#getBlockData, rename… (#7039)
PaperMC/Paper@b8d486c Create workflow to add new PRs to the PR Queue project (#6918)
PaperMC/Paper@a50e273 Include axolotls in affected entities for water splash potions (#7024)
PaperMC/Paper@af95df8 Port Actually unload POI data from Tuinity 1.16 (#7044)
PaperMC/Paper@04897b1 [ci skip] Revert "Create workflow to add new PRs to the PR Queue project (#6918)" (#7046)
PaperMC/Paper@b4a77a8 Updated Upstream (Bukkit/CraftBukkit) (#7045)
PaperMC/Paper@0e25db2 Fix mis-placed processEnchantOrder from 1.18 update (#7052)
PaperMC/Paper@53d026e Fix unused EntitySectionStorage#getEntities(AABB, Consumer) method being broken
PaperMC/Paper@772e880 Fix light propagation in high y sections
PaperMC/Paper@33ea869 Bump Starlight light version
PaperMC/Paper@74fd151 Fix entity equipment on cancellation of EntityDeathEvent (#5740)
PaperMC/Paper@758e2a7 Fix bad ticking checks for blocks
PaperMC/Paper@0e91b6a Return 0 for light values if a dimenion does not have them
PaperMC/Paper@188a8df Fix ChunkSnapshot#isSectionEmpty(int)
PaperMC/Paper@bbc7451 Fix issue with snapshotted biomes in last commit
PaperMC/Paper@b475c6a Backport log4j fix
PaperMC/Paper@4e355c4 Updated Upstream (CraftBukkit)
PaperMC/Paper@dce79f3 Update Log4J (#7069)
2021-12-09 22:46:19 -05:00

106 lines
5.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Mon, 28 Jun 2021 13:33:12 -0500
Subject: [PATCH] Redirect System.out calls to plugin loggers
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 455776981274e64724376a3182b60784b56db9cf..cd859eec6b0bee44bce83614e55709381baf5e6b 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -176,8 +176,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
*/
// Paper end
- System.setOut(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream());
- System.setErr(IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream());
+ System.setOut(new org.purpurmc.purpur.PurpurPrintStream(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream(), java.util.logging.Logger::info)); // Purpur
+ System.setErr(new org.purpurmc.purpur.PurpurPrintStream(IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream(), java.util.logging.Logger::severe)); // Purpur
// CraftBukkit end
thread.setDaemon(true);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index d397daf9a6b2128735a0732565a41be9197742a4..52686415c7a37c14c16537d44f6b2c6420accb87 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -293,7 +293,7 @@ public final class CraftServer implements Server {
public int reloadCount;
private final io.papermc.paper.datapack.PaperDatapackManager datapackManager; // Paper
public static Exception excessiveVelEx; // Paper - Velocity warnings
- private final SysoutCatcher sysoutCatcher = new SysoutCatcher(); // Paper
+ //private final SysoutCatcher sysoutCatcher = new SysoutCatcher(); // Paper // Purpur - we have our own implementation that doesnt nag or prefix output
static {
ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
diff --git a/src/main/java/org/purpurmc/purpur/PurpurPrintStream.java b/src/main/java/org/purpurmc/purpur/PurpurPrintStream.java
new file mode 100644
index 0000000000000000000000000000000000000000..f39c451f8877c7cb66fd4761006176107eceeac6
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/PurpurPrintStream.java
@@ -0,0 +1,65 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Josh (Vicarious)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.purpurmc.purpur;
+
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.function.BiConsumer;
+import java.util.logging.Logger;
+
+/**
+ * Logic borrowed from SysoutCatcher
+ * <p>
+ * https://www.spigotmc.org/resources/sysoutcatcher.79076/
+ */
+
+public class PurpurPrintStream extends PrintStream {
+ private static final StackWalker STACKWALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
+ private final BiConsumer<Logger, String> consumer;
+
+ public PurpurPrintStream(@NotNull OutputStream out, BiConsumer<Logger, String> consumer) {
+ super(out);
+ this.consumer = consumer;
+ }
+
+ @Override
+ public void println(String line) {
+ try {
+ // Get the JavaPlugin that "owns" the calling class
+ JavaPlugin plugin = JavaPlugin.getProvidingPlugin(STACKWALKER.getCallerClass());
+
+ // Instead of just printing the message, send it to the plugin's logger
+ consumer.accept(plugin.getLogger(), line);
+ } catch (Throwable ignore) {
+ // If anything happens, the calling class doesn't exist, there is no JavaPlugin that "owns" the calling class, etc
+ // Just print out normally, with some added information
+ StackTraceElement element = Thread.currentThread().getStackTrace()[2];
+ consumer.accept(Bukkit.getLogger(), String.format("(%s:%d) %s", element.getClassName(), element.getLineNumber(), line));
+ }
+ }
+}