mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@a3dfe6d Updated Upstream (Bukkit/CraftBukkit/Spigot) (#6722) PaperMC/Paper@fdd5c65 Fix CraftCriteria defaults map (#6723) PaperMC/Paper@d54e8c5 Support components in command permission msgs (#6676) PaperMC/Paper@e155002 Fix EntityPortalExitEvent not being called (#5617) PaperMC/Paper@e4d8c47 Update adventure and fix command perm serialization NPE (#6729) PaperMC/Paper@0cdeeef Remove unnecessary Velocity repo from server (#6730) PaperMC/Paper@a419941 Add download link to the /version command (#6482) PaperMC/Paper@8e661c6 Deprecate API methods added by 'Close Plugin Class Loaders on Disable' (#6737) PaperMC/Paper@7991c4b Fix upstream block state factories (#6738) PaperMC/Paper@bfe5622 Fix EntityPortalExitEvent target location PaperMC/Paper@3391ccf Discard out of bounds chunks during regionfile header recalculation PaperMC/Paper@cf4af9f Add config setting for logging player ip addresses. (#6342) PaperMC/Paper@6dfc0f5 Add getChangedBlockData() property to BlockPhysicsEvent to expose BlockData (#6743) PaperMC/Paper@0d1e187 Fix kicking ops when whitelist is reloaded (MC-171420) (#6742) PaperMC/Paper@975f2e5 Filter ip address on join if setting is true (#6748)
106 lines
5.3 KiB
Diff
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 9cff21030215ab60a219fa719e8140c0c331a06b..f2e6676cbcf66e3334d5a76a03b1c1e8862504d3 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -178,8 +178,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 net.pl3x.purpur.PurpurPrintStream(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream(), java.util.logging.Logger::info)); // Purpur
|
|
+ System.setErr(new net.pl3x.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/net/pl3x/purpur/PurpurPrintStream.java b/src/main/java/net/pl3x/purpur/PurpurPrintStream.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..f88da0b86a683b25d429ceea4a36d6dde12b2b56
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/pl3x/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 net.pl3x.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));
|
|
+ }
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 64fa32a25e5e2d745d7605dfb1439f0e087dc304..1cdc15dc93b64887abbc5e7df1a91fc4705df169 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -291,7 +291,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);
|