mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 17:57:34 +01:00
SPIGOT-6063: ConsoleSender sending extra lines in Java 13+
By: md_5 <git@md-5.net>
This commit is contained in:
parent
c6d968eda2
commit
3c76d377fa
@ -1,24 +1,21 @@
|
|||||||
--- a/net/minecraft/server/DedicatedServer.java
|
--- a/net/minecraft/server/DedicatedServer.java
|
||||||
+++ b/net/minecraft/server/DedicatedServer.java
|
+++ b/net/minecraft/server/DedicatedServer.java
|
||||||
@@ -22,6 +22,17 @@
|
@@ -22,6 +22,14 @@
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import java.io.PrintStream;
|
|
||||||
+import org.apache.logging.log4j.Level;
|
+import org.apache.logging.log4j.Level;
|
||||||
+
|
+import org.apache.logging.log4j.io.IoBuilder;
|
||||||
+import org.bukkit.command.CommandSender;
|
+import org.bukkit.command.CommandSender;
|
||||||
+import org.bukkit.craftbukkit.LoggerOutputStream;
|
|
||||||
+import org.bukkit.event.server.ServerCommandEvent;
|
+import org.bukkit.event.server.ServerCommandEvent;
|
||||||
+import org.bukkit.craftbukkit.util.Waitable;
|
|
||||||
+import org.bukkit.event.server.RemoteServerCommandEvent;
|
+import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||||
+// CraftBukkit end
|
+// CraftBukkit end
|
||||||
+
|
+
|
||||||
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
|
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
@@ -34,8 +45,10 @@
|
@@ -34,8 +42,10 @@
|
||||||
@Nullable
|
@Nullable
|
||||||
private ServerGUI q;
|
private ServerGUI q;
|
||||||
|
|
||||||
@ -31,7 +28,7 @@
|
|||||||
this.propertyManager = dedicatedserversettings;
|
this.propertyManager = dedicatedserversettings;
|
||||||
this.remoteControlCommandListener = new RemoteControlCommandListener(this);
|
this.remoteControlCommandListener = new RemoteControlCommandListener(this);
|
||||||
}
|
}
|
||||||
@@ -44,13 +57,44 @@
|
@@ -44,13 +54,44 @@
|
||||||
public boolean init() throws IOException {
|
public boolean init() throws IOException {
|
||||||
Thread thread = new Thread("Server console handler") {
|
Thread thread = new Thread("Server console handler") {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -79,7 +76,7 @@
|
|||||||
}
|
}
|
||||||
} catch (IOException ioexception) {
|
} catch (IOException ioexception) {
|
||||||
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
||||||
@@ -59,6 +103,27 @@
|
@@ -59,6 +100,27 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -100,14 +97,14 @@
|
|||||||
+
|
+
|
||||||
+ new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader).start();
|
+ new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader).start();
|
||||||
+
|
+
|
||||||
+ System.setOut(new PrintStream(new LoggerOutputStream(logger, Level.INFO), true));
|
+ System.setOut(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream());
|
||||||
+ System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true));
|
+ System.setErr(IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream());
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
+
|
||||||
thread.setDaemon(true);
|
thread.setDaemon(true);
|
||||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
|
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
|
||||||
thread.start();
|
thread.start();
|
||||||
@@ -85,7 +150,7 @@
|
@@ -85,7 +147,7 @@
|
||||||
this.setForceGamemode(dedicatedserverproperties.forceGamemode);
|
this.setForceGamemode(dedicatedserverproperties.forceGamemode);
|
||||||
super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
|
super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
|
||||||
this.i(dedicatedserverproperties.enforceWhitelist);
|
this.i(dedicatedserverproperties.enforceWhitelist);
|
||||||
@ -116,7 +113,7 @@
|
|||||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||||
InetAddress inetaddress = null;
|
InetAddress inetaddress = null;
|
||||||
|
|
||||||
@@ -110,6 +175,12 @@
|
@@ -110,6 +172,12 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +126,7 @@
|
|||||||
if (!this.getOnlineMode()) {
|
if (!this.getOnlineMode()) {
|
||||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||||
@@ -124,7 +195,7 @@
|
@@ -124,7 +192,7 @@
|
||||||
if (!NameReferencingFileConverter.e(this)) {
|
if (!NameReferencingFileConverter.e(this)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@ -138,7 +135,7 @@
|
|||||||
long i = SystemUtils.getMonotonicNanos();
|
long i = SystemUtils.getMonotonicNanos();
|
||||||
|
|
||||||
this.c(dedicatedserverproperties.maxBuildHeight);
|
this.c(dedicatedserverproperties.maxBuildHeight);
|
||||||
@@ -132,7 +203,7 @@
|
@@ -132,7 +200,7 @@
|
||||||
TileEntitySkull.a(this.getMinecraftSessionService());
|
TileEntitySkull.a(this.getMinecraftSessionService());
|
||||||
UserCache.a(this.getOnlineMode());
|
UserCache.a(this.getOnlineMode());
|
||||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld());
|
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld());
|
||||||
@ -147,7 +144,7 @@
|
|||||||
long j = SystemUtils.getMonotonicNanos() - i;
|
long j = SystemUtils.getMonotonicNanos() - i;
|
||||||
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
|
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
|
||||||
|
|
||||||
@@ -149,6 +220,7 @@
|
@@ -149,6 +217,7 @@
|
||||||
if (dedicatedserverproperties.enableRcon) {
|
if (dedicatedserverproperties.enableRcon) {
|
||||||
DedicatedServer.LOGGER.info("Starting remote control listener");
|
DedicatedServer.LOGGER.info("Starting remote control listener");
|
||||||
this.remoteControlListener = RemoteControlListener.a((IMinecraftServer) this);
|
this.remoteControlListener = RemoteControlListener.a((IMinecraftServer) this);
|
||||||
@ -155,7 +152,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.getMaxTickTime() > 0L) {
|
if (this.getMaxTickTime() > 0L) {
|
||||||
@@ -259,6 +331,7 @@
|
@@ -259,6 +328,7 @@
|
||||||
this.remoteStatusListener.b();
|
this.remoteStatusListener.b();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +160,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -287,7 +360,15 @@
|
@@ -287,7 +357,15 @@
|
||||||
while (!this.serverCommandQueue.isEmpty()) {
|
while (!this.serverCommandQueue.isEmpty()) {
|
||||||
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
|
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
|
||||||
|
|
||||||
@ -180,7 +177,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -497,14 +578,45 @@
|
@@ -497,14 +575,45 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlugins() {
|
public String getPlugins() {
|
||||||
@ -228,7 +225,7 @@
|
|||||||
});
|
});
|
||||||
return this.remoteControlCommandListener.getMessages();
|
return this.remoteControlCommandListener.getMessages();
|
||||||
}
|
}
|
||||||
@@ -540,4 +652,15 @@
|
@@ -540,4 +649,15 @@
|
||||||
public boolean isSyncChunkWrites() {
|
public boolean isSyncChunkWrites() {
|
||||||
return this.propertyManager.getProperties().syncChunkWrites;
|
return this.propertyManager.getProperties().syncChunkWrites;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,12 @@
|
|||||||
<version>2.12.1</version>
|
<version>2.12.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-iostreams</artifactId>
|
||||||
|
<version>2.8.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.ow2.asm</groupId>
|
<groupId>org.ow2.asm</groupId>
|
||||||
<artifactId>asm</artifactId>
|
<artifactId>asm</artifactId>
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package org.bukkit.craftbukkit;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import org.apache.logging.log4j.Level;
|
|
||||||
import org.apache.logging.log4j.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.log(level, record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user