2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-03-08 15:08:21 +00:00
|
|
|
From: Minecrell <minecrell@minecrell.net>
|
2017-06-09 17:05:12 +00:00
|
|
|
Date: Fri, 9 Jun 2017 19:03:43 +0200
|
|
|
|
Subject: [PATCH] Use TerminalConsoleAppender for console improvements
|
|
|
|
|
|
|
|
Rewrite console improvements (console colors, tab completion,
|
|
|
|
persistent input line, ...) using JLine 3.x and TerminalConsoleAppender.
|
|
|
|
|
|
|
|
New features:
|
|
|
|
- Support console colors for Vanilla commands
|
|
|
|
- Add console colors for warnings and errors
|
|
|
|
- Server can now be turned off safely using CTRL + C. JLine catches
|
|
|
|
the signal and the implementation shuts down the server cleanly.
|
|
|
|
- Support console colors and persistent input line when running in
|
|
|
|
IntelliJ IDEA
|
|
|
|
|
|
|
|
Other changes:
|
|
|
|
- Server starts 1-2 seconds faster thanks to optimizations in Log4j
|
|
|
|
configuration
|
|
|
|
|
|
|
|
diff --git a/pom.xml b/pom.xml
|
2021-04-11 17:35:46 +00:00
|
|
|
index 5710dd02c80bc713e5dd289c9aa4bc21fd0f4318..e0fcbe1b13a5ec1244d6d904ca76336a47967c9b 100644
|
2017-06-09 17:05:12 +00:00
|
|
|
--- a/pom.xml
|
|
|
|
+++ b/pom.xml
|
2021-04-11 17:07:39 +00:00
|
|
|
@@ -57,10 +57,26 @@
|
2017-06-09 17:05:12 +00:00
|
|
|
<scope>compile</scope>
|
|
|
|
</dependency>
|
2018-08-26 18:11:49 +00:00
|
|
|
<dependency>
|
2017-06-09 17:05:12 +00:00
|
|
|
- <groupId>jline</groupId>
|
|
|
|
- <artifactId>jline</artifactId>
|
|
|
|
- <version>2.12.1</version>
|
|
|
|
- <scope>compile</scope>
|
|
|
|
+ <groupId>net.minecrell</groupId>
|
|
|
|
+ <artifactId>terminalconsoleappender</artifactId>
|
2019-07-24 00:25:05 +00:00
|
|
|
+ <version>1.2.0</version>
|
2017-06-09 17:05:12 +00:00
|
|
|
+ </dependency>
|
|
|
|
+ <dependency>
|
2019-07-24 00:25:05 +00:00
|
|
|
+ <groupId>org.jline</groupId>
|
|
|
|
+ <artifactId>jline-terminal-jansi</artifactId>
|
|
|
|
+ <version>3.12.1</version>
|
2017-06-09 17:05:12 +00:00
|
|
|
+ <scope>runtime</scope>
|
|
|
|
+ </dependency>
|
|
|
|
+ <!--
|
|
|
|
+ Required to add the missing Log4j2Plugins.dat file from log4j-core
|
|
|
|
+ which has been removed by Mojang. Without it, log4j has to classload
|
|
|
|
+ all its classes to check if they are plugins.
|
|
|
|
+ Scanning takes about 1-2 seconds so adding this speeds up the server start.
|
|
|
|
+ -->
|
|
|
|
+ <dependency>
|
|
|
|
+ <groupId>org.apache.logging.log4j</groupId>
|
|
|
|
+ <artifactId>log4j-core</artifactId>
|
|
|
|
+ <scope>runtime</scope>
|
2018-08-26 18:11:49 +00:00
|
|
|
</dependency>
|
2017-06-09 17:05:12 +00:00
|
|
|
<dependency>
|
2020-09-12 19:57:21 +00:00
|
|
|
<groupId>org.apache.logging.log4j</groupId>
|
2021-04-11 17:07:39 +00:00
|
|
|
@@ -276,10 +292,18 @@
|
2017-06-09 17:05:12 +00:00
|
|
|
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
|
|
|
|
<resource>META-INF/services/java.sql.Driver</resource>
|
|
|
|
</transformer>
|
2020-04-27 07:34:45 +00:00
|
|
|
+ <transformer implementation="com.github.edwgiz.maven_shade_plugin.log4j2_cache_transformer.PluginsCacheFileTransformer" />
|
2017-06-09 17:05:12 +00:00
|
|
|
</transformers>
|
|
|
|
</configuration>
|
|
|
|
</execution>
|
|
|
|
</executions>
|
|
|
|
+ <dependencies>
|
|
|
|
+ <dependency>
|
|
|
|
+ <groupId>com.github.edwgiz</groupId>
|
|
|
|
+ <artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId>
|
2020-04-27 07:34:45 +00:00
|
|
|
+ <version>2.13.1</version>
|
2017-06-09 17:05:12 +00:00
|
|
|
+ </dependency>
|
|
|
|
+ </dependencies>
|
|
|
|
</plugin>
|
|
|
|
<plugin>
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
2018-07-17 12:48:52 +00:00
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
|
|
|
new file mode 100644
|
2021-03-16 13:04:28 +00:00
|
|
|
index 0000000000000000000000000000000000000000..89eeb9d202405747409e65fcf226d95379987e29
|
2018-07-17 12:48:52 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
2020-05-23 03:23:27 +00:00
|
|
|
@@ -0,0 +1,41 @@
|
2018-07-17 12:48:52 +00:00
|
|
|
+package com.destroystokyo.paper.console;
|
|
|
|
+
|
2021-03-16 13:04:28 +00:00
|
|
|
+import net.minecraft.server.dedicated.DedicatedServer;
|
2018-07-17 12:48:52 +00:00
|
|
|
+import net.minecrell.terminalconsole.SimpleTerminalConsole;
|
|
|
|
+import org.bukkit.craftbukkit.command.ConsoleCommandCompleter;
|
|
|
|
+import org.jline.reader.LineReader;
|
|
|
|
+import org.jline.reader.LineReaderBuilder;
|
|
|
|
+
|
|
|
|
+public final class PaperConsole extends SimpleTerminalConsole {
|
|
|
|
+
|
|
|
|
+ private final DedicatedServer server;
|
|
|
|
+
|
|
|
|
+ public PaperConsole(DedicatedServer server) {
|
|
|
|
+ this.server = server;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected LineReader buildReader(LineReaderBuilder builder) {
|
|
|
|
+ return super.buildReader(builder
|
|
|
|
+ .appName("Paper")
|
2020-05-23 03:23:27 +00:00
|
|
|
+ .variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
|
2018-07-17 12:48:52 +00:00
|
|
|
+ .completer(new ConsoleCommandCompleter(this.server))
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected boolean isRunning() {
|
|
|
|
+ return !this.server.isStopped() && this.server.isRunning();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void runCommand(String command) {
|
2018-07-19 19:23:18 +00:00
|
|
|
+ this.server.issueCommand(command, this.server.getServerCommandListener());
|
2018-07-17 12:48:52 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void shutdown() {
|
2019-05-05 23:24:37 +00:00
|
|
|
+ this.server.safeShutdown(false);
|
2018-07-17 12:48:52 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
2017-06-09 17:05:12 +00:00
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java
|
|
|
|
new file mode 100644
|
2020-05-06 09:48:49 +00:00
|
|
|
index 0000000000000000000000000000000000000000..685deaa0e5d1ddc13e3a7c0471b1cfcf1710c869
|
2017-06-09 17:05:12 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java
|
2017-06-21 08:46:18 +00:00
|
|
|
@@ -0,0 +1,17 @@
|
2017-06-09 17:05:12 +00:00
|
|
|
+package com.destroystokyo.paper.console;
|
|
|
|
+
|
2017-06-21 08:46:18 +00:00
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
|
+import org.apache.logging.log4j.Logger;
|
2017-06-09 17:05:12 +00:00
|
|
|
+import org.bukkit.craftbukkit.command.CraftConsoleCommandSender;
|
|
|
|
+
|
|
|
|
+public class TerminalConsoleCommandSender extends CraftConsoleCommandSender {
|
|
|
|
+
|
2017-06-21 08:46:18 +00:00
|
|
|
+ private static final Logger LOGGER = LogManager.getRootLogger();
|
|
|
|
+
|
2017-06-09 17:05:12 +00:00
|
|
|
+ @Override
|
|
|
|
+ public void sendRawMessage(String message) {
|
2017-06-21 08:46:18 +00:00
|
|
|
+ // TerminalConsoleAppender supports color codes directly in log messages
|
|
|
|
+ LOGGER.info(message);
|
2017-06-09 17:05:12 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2021-03-16 15:50:45 +00:00
|
|
|
index 7637e17e8a811214931c2df3dab50651a4cbcde6..d181a41c1724ee6e84f5239649ab74df158d5f24 100644
|
2017-06-09 17:05:12 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2021-03-16 15:50:45 +00:00
|
|
|
@@ -160,7 +160,7 @@ import org.apache.logging.log4j.Logger;
|
2021-03-08 23:12:31 +00:00
|
|
|
import com.mojang.serialization.DynamicOps;
|
|
|
|
import com.mojang.serialization.Lifecycle;
|
2020-06-25 14:09:55 +00:00
|
|
|
import com.google.common.collect.ImmutableSet;
|
2017-06-09 17:05:12 +00:00
|
|
|
-import jline.console.ConsoleReader;
|
2020-06-25 14:09:55 +00:00
|
|
|
+// import jline.console.ConsoleReader; // Paper
|
2020-06-25 13:11:48 +00:00
|
|
|
import joptsimple.OptionSet;
|
2021-03-16 07:19:45 +00:00
|
|
|
import net.minecraft.nbt.DynamicOpsNBT;
|
|
|
|
import net.minecraft.nbt.NBTBase;
|
2021-03-16 15:50:45 +00:00
|
|
|
@@ -255,7 +255,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2017-06-09 17:05:12 +00:00
|
|
|
public OptionSet options;
|
|
|
|
public org.bukkit.command.ConsoleCommandSender console;
|
|
|
|
public org.bukkit.command.RemoteConsoleCommandSender remoteConsole;
|
|
|
|
- public ConsoleReader reader;
|
|
|
|
+ //public ConsoleReader reader; // Paper
|
|
|
|
public static int currentTick = 0; // Paper - Further improve tick loop
|
2019-04-27 06:26:04 +00:00
|
|
|
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
|
|
|
public int autosavePeriod;
|
2021-03-16 15:50:45 +00:00
|
|
|
@@ -324,7 +324,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2017-06-09 17:05:12 +00:00
|
|
|
this.options = options;
|
2020-06-25 13:11:48 +00:00
|
|
|
this.datapackconfiguration = datapackconfiguration;
|
|
|
|
this.vanillaCommandDispatcher = datapackresources.commandDispatcher; // CraftBukkit
|
2017-06-09 17:05:12 +00:00
|
|
|
+ // Paper start - Handled by TerminalConsoleAppender
|
|
|
|
// Try to see if we're actually running in a terminal, disable jline if not
|
|
|
|
+ /*
|
|
|
|
if (System.console() == null && System.getProperty("jline.terminal") == null) {
|
|
|
|
System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
|
|
|
|
Main.useJline = false;
|
2021-03-16 15:50:45 +00:00
|
|
|
@@ -345,6 +347,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2017-06-09 17:05:12 +00:00
|
|
|
LOGGER.warn((String) null, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ */
|
|
|
|
+ // Paper end
|
|
|
|
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
2019-04-27 06:26:04 +00:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2021-03-16 15:50:45 +00:00
|
|
|
@@ -1088,7 +1092,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2019-12-23 02:37:47 +00:00
|
|
|
org.spigotmc.WatchdogThread.doStop(); // Spigot
|
2017-06-09 17:05:12 +00:00
|
|
|
// CraftBukkit start - Restore terminal to original settings
|
|
|
|
try {
|
|
|
|
- reader.getTerminal().restore();
|
|
|
|
+ net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2021-03-16 15:50:45 +00:00
|
|
|
@@ -1459,7 +1463,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2017-06-09 17:05:12 +00:00
|
|
|
|
2019-04-27 06:26:04 +00:00
|
|
|
@Override
|
2020-06-25 13:11:48 +00:00
|
|
|
public void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid) {
|
2018-07-18 00:08:13 +00:00
|
|
|
- MinecraftServer.LOGGER.info(ichatbasecomponent.getString());
|
2020-06-02 03:15:47 +00:00
|
|
|
+ MinecraftServer.LOGGER.info(org.bukkit.craftbukkit.util.CraftChatMessage.fromComponent(ichatbasecomponent));// Paper - Log message with colors
|
2017-06-09 17:05:12 +00:00
|
|
|
}
|
|
|
|
|
2019-04-27 06:26:04 +00:00
|
|
|
public KeyPair getKeyPair() {
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
|
|
index 8ae72e8c8325d9b03803f29fcdd83a0ce8d34450..a0804c4df6f047cf913ae70970219617052e853f 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
|
|
@@ -102,6 +102,9 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
|
|
|
if (!org.bukkit.craftbukkit.Main.useConsole) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
+ // Paper start - Use TerminalConsoleAppender
|
|
|
|
+ new com.destroystokyo.paper.console.PaperConsole(DedicatedServer.this).start();
|
|
|
|
+ /*
|
|
|
|
jline.console.ConsoleReader bufferedreader = reader;
|
|
|
|
|
|
|
|
// MC-33041, SPIGOT-5538: if System.in is not valid due to javaw, then return
|
|
|
|
@@ -141,6 +144,8 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
|
|
|
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ */
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
@@ -152,6 +157,9 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
|
|
|
}
|
|
|
|
global.addHandler(new org.bukkit.craftbukkit.util.ForwardLogHandler());
|
|
|
|
|
|
|
|
+ // Paper start - Not needed with TerminalConsoleAppender
|
|
|
|
+ final org.apache.logging.log4j.Logger logger = LogManager.getRootLogger();
|
|
|
|
+ /*
|
|
|
|
final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger());
|
|
|
|
for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values()) {
|
|
|
|
if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) {
|
|
|
|
@@ -160,6 +168,8 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
|
|
|
}
|
|
|
|
|
|
|
|
new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader).start();
|
|
|
|
+ */
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
System.setOut(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream());
|
|
|
|
System.setErr(IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream());
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2021-03-16 15:50:45 +00:00
|
|
|
index 6c80f328016b6cd30c77b5a5b1e2f6be0b3cd2f0..a892bcf08dddac90f01caec81229259e1070c3ea 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -150,8 +150,7 @@ public abstract class PlayerList {
|
2017-06-09 17:05:12 +00:00
|
|
|
|
2020-06-25 13:11:48 +00:00
|
|
|
public PlayerList(MinecraftServer minecraftserver, IRegistryCustom.Dimension iregistrycustom_dimension, WorldNBTStorage worldnbtstorage, int i) {
|
2019-04-27 06:26:04 +00:00
|
|
|
this.cserver = minecraftserver.server = new CraftServer((DedicatedServer) minecraftserver, this);
|
2017-06-09 17:05:12 +00:00
|
|
|
- minecraftserver.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance();
|
|
|
|
- minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server));
|
|
|
|
+ minecraftserver.console = new com.destroystokyo.paper.console.TerminalConsoleCommandSender(); // Paper
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2019-12-11 23:43:22 +00:00
|
|
|
this.k = new GameProfileBanList(PlayerList.b);
|
2017-06-09 17:05:12 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2021-03-16 07:19:45 +00:00
|
|
|
index 1f0021c5374e1af9c9cd29d44e6b0bd9522394d9..5d357b0f84b5242066dcce203752a0f46e9a249c 100644
|
2017-06-09 17:05:12 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -46,7 +46,6 @@ import java.util.function.Consumer;
|
2020-04-27 07:34:45 +00:00
|
|
|
import java.util.logging.Level;
|
2019-04-27 06:26:04 +00:00
|
|
|
import java.util.logging.Logger;
|
|
|
|
import javax.imageio.ImageIO;
|
2017-06-09 17:05:12 +00:00
|
|
|
-import jline.console.ConsoleReader;
|
2021-03-16 07:19:45 +00:00
|
|
|
import net.minecraft.advancements.Advancement;
|
|
|
|
import net.minecraft.commands.CommandDispatcher;
|
|
|
|
import net.minecraft.commands.CommandListenerWrapper;
|
|
|
|
@@ -59,6 +58,7 @@ import net.minecraft.nbt.NBTBase;
|
|
|
|
import net.minecraft.resources.MinecraftKey;
|
|
|
|
import net.minecraft.resources.RegistryReadOps;
|
|
|
|
import net.minecraft.resources.ResourceKey;
|
2020-04-27 07:34:45 +00:00
|
|
|
+//import jline.console.ConsoleReader; // Paper
|
2021-03-16 07:19:45 +00:00
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
import net.minecraft.server.ServerCommand;
|
|
|
|
import net.minecraft.server.bossevents.BossBattleCustom;
|
2021-02-21 20:55:01 +00:00
|
|
|
@@ -1201,9 +1201,13 @@ public final class CraftServer implements Server {
|
2017-06-09 17:05:12 +00:00
|
|
|
return logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - JLine update
|
|
|
|
+ /*
|
|
|
|
public ConsoleReader getReader() {
|
|
|
|
return console.reader;
|
|
|
|
}
|
|
|
|
+ */
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public PluginCommand getPluginCommand(String name) {
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
2021-04-11 17:07:39 +00:00
|
|
|
index 0c069673437d97aff29b3a30caa22fcf62d0d7db..fb49dd66e40e8376e9d6141b97350e16b5d0215e 100644
|
2017-06-09 17:05:12 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
2020-06-25 13:11:48 +00:00
|
|
|
@@ -12,7 +12,7 @@ import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
2017-06-09 17:05:12 +00:00
|
|
|
import joptsimple.OptionParser;
|
|
|
|
import joptsimple.OptionSet;
|
|
|
|
-import org.fusesource.jansi.AnsiConsole;
|
|
|
|
+import net.minecrell.terminalconsole.TerminalConsoleAppender; // Paper
|
|
|
|
|
|
|
|
public class Main {
|
|
|
|
public static boolean useJline = true;
|
2020-01-22 02:02:07 +00:00
|
|
|
@@ -179,6 +179,8 @@ public class Main {
|
2017-06-09 17:05:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
+ // Paper start - Handled by TerminalConsoleAppender
|
|
|
|
+ /*
|
|
|
|
// This trick bypasses Maven Shade's clever rewriting of our getProperty call when using String literals
|
2020-04-27 07:34:45 +00:00
|
|
|
String jline_UnsupportedTerminal = new String(new char[]{'j', 'l', 'i', 'n', 'e', '.', 'U', 'n', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd', 'T', 'e', 'r', 'm', 'i', 'n', 'a', 'l'});
|
|
|
|
String jline_terminal = new String(new char[]{'j', 'l', 'i', 'n', 'e', '.', 't', 'e', 'r', 'm', 'i', 'n', 'a', 'l'});
|
|
|
|
@@ -196,9 +198,18 @@ public class Main {
|
2017-06-09 17:05:12 +00:00
|
|
|
// This ensures the terminal literal will always match the jline implementation
|
|
|
|
System.setProperty(jline.TerminalFactory.JLINE_TERMINAL, jline.UnsupportedTerminal.class.getName());
|
|
|
|
}
|
|
|
|
+ */
|
2020-04-27 07:34:45 +00:00
|
|
|
+
|
2017-06-09 17:05:12 +00:00
|
|
|
+ if (options.has("nojline")) {
|
|
|
|
+ System.setProperty(TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false");
|
|
|
|
+ useJline = false;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
if (options.has("noconsole")) {
|
|
|
|
useConsole = false;
|
|
|
|
+ useJline = false; // Paper
|
|
|
|
+ System.setProperty(TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false"); // Paper
|
|
|
|
}
|
|
|
|
|
2021-01-16 02:18:08 +00:00
|
|
|
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
|
2020-04-27 07:34:45 +00:00
|
|
|
@@ -226,7 +237,7 @@ public class Main {
|
2019-10-13 21:35:54 +00:00
|
|
|
System.out.println("Unable to read system info");
|
|
|
|
}
|
|
|
|
// Paper end
|
|
|
|
-
|
|
|
|
+ System.setProperty( "library.jansi.version", "Paper" ); // Paper - set meaningless jansi version to prevent git builds from crashing on Windows
|
|
|
|
System.out.println("Loading libraries, please wait...");
|
2020-06-25 13:11:48 +00:00
|
|
|
net.minecraft.server.Main.main(options);
|
2019-10-13 21:35:54 +00:00
|
|
|
} catch (Throwable t) {
|
2017-06-09 17:05:12 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
|
2020-08-27 13:37:37 +00:00
|
|
|
index 4580642e0ee79e6d9c9bef0344e643bbc551205c..829c62b6d55cb5706be3ce6bdc758d6b204844ee 100644
|
2017-06-09 17:05:12 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
|
2020-04-27 07:34:45 +00:00
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
|
2020-08-27 13:37:37 +00:00
|
|
|
@@ -5,15 +5,13 @@ import java.util.EnumMap;
|
2020-04-27 07:34:45 +00:00
|
|
|
import java.util.Map;
|
2020-08-27 13:37:37 +00:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
2017-06-09 17:05:12 +00:00
|
|
|
-import jline.Terminal;
|
2020-04-27 07:34:45 +00:00
|
|
|
+//import jline.Terminal;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.ConsoleCommandSender;
|
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2019-04-27 06:26:04 +00:00
|
|
|
-import org.fusesource.jansi.Ansi;
|
|
|
|
-import org.fusesource.jansi.Ansi.Attribute;
|
2020-04-27 07:34:45 +00:00
|
|
|
|
2017-06-09 17:05:12 +00:00
|
|
|
-public class ColouredConsoleSender extends CraftConsoleCommandSender {
|
2020-04-27 07:34:45 +00:00
|
|
|
+public class ColouredConsoleSender /*extends CraftConsoleCommandSender */{/* // Paper - disable
|
|
|
|
private final Terminal terminal;
|
|
|
|
private final Map<ChatColor, String> replacements = new EnumMap<ChatColor, String>(ChatColor.class);
|
|
|
|
private final ChatColor[] colors = ChatColor.values();
|
2020-08-27 13:37:37 +00:00
|
|
|
@@ -93,5 +91,5 @@ public class ColouredConsoleSender extends CraftConsoleCommandSender {
|
2020-04-27 07:34:45 +00:00
|
|
|
} else {
|
|
|
|
return new ColouredConsoleSender();
|
|
|
|
}
|
2017-06-09 17:05:12 +00:00
|
|
|
- }
|
2020-04-27 07:34:45 +00:00
|
|
|
+ }*/ // Paper
|
|
|
|
}
|
2017-06-09 17:05:12 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
|
2021-03-16 13:04:28 +00:00
|
|
|
index befcc19f9b56df9096b98a23b0020f1db793ea5b..a957695457cf3252848ce6ef37069692841b8e28 100644
|
2017-06-09 17:05:12 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
|
2019-05-06 02:58:04 +00:00
|
|
|
@@ -4,20 +4,31 @@ import java.util.Collections;
|
2019-04-27 06:26:04 +00:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.logging.Level;
|
|
|
|
-import jline.console.completer.Completer;
|
2021-03-16 13:04:28 +00:00
|
|
|
+import net.minecraft.server.dedicated.DedicatedServer;
|
2017-06-09 17:05:12 +00:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
|
|
import org.bukkit.craftbukkit.util.Waitable;
|
2019-04-27 06:26:04 +00:00
|
|
|
+
|
2017-06-09 17:05:12 +00:00
|
|
|
+// Paper start - JLine update
|
|
|
|
+import org.jline.reader.Candidate;
|
|
|
|
+import org.jline.reader.Completer;
|
|
|
|
+import org.jline.reader.LineReader;
|
|
|
|
+import org.jline.reader.ParsedLine;
|
|
|
|
+// Paper end
|
|
|
|
import org.bukkit.event.server.TabCompleteEvent;
|
|
|
|
|
|
|
|
public class ConsoleCommandCompleter implements Completer {
|
|
|
|
- private final CraftServer server;
|
|
|
|
+ private final DedicatedServer server; // Paper - CraftServer -> DedicatedServer
|
|
|
|
|
|
|
|
- public ConsoleCommandCompleter(CraftServer server) {
|
|
|
|
+ public ConsoleCommandCompleter(DedicatedServer server) { // Paper - CraftServer -> DedicatedServer
|
|
|
|
this.server = server;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Change method signature for JLine update
|
2019-05-06 02:58:04 +00:00
|
|
|
@Override
|
|
|
|
- public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) {
|
2017-06-09 17:05:12 +00:00
|
|
|
+ public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
|
|
|
|
+ final CraftServer server = this.server.server;
|
|
|
|
+ final String buffer = line.line();
|
|
|
|
+ // Paper end
|
|
|
|
Waitable<List<String>> waitable = new Waitable<List<String>>() {
|
|
|
|
@Override
|
|
|
|
protected List<String> evaluate() {
|
2019-05-06 02:58:04 +00:00
|
|
|
@@ -29,25 +40,37 @@ public class ConsoleCommandCompleter implements Completer {
|
2017-06-09 17:05:12 +00:00
|
|
|
return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
- this.server.getServer().processQueue.add(waitable);
|
|
|
|
+ server.getServer().processQueue.add(waitable); // Paper - Remove "this."
|
|
|
|
try {
|
|
|
|
List<String> offers = waitable.get();
|
|
|
|
if (offers == null) {
|
|
|
|
- return cursor;
|
|
|
|
+ return; // Paper - Method returns void
|
2019-04-27 06:26:04 +00:00
|
|
|
+ }
|
|
|
|
+
|
2017-06-09 17:05:12 +00:00
|
|
|
+ // Paper start - JLine update
|
|
|
|
+ for (String completion : offers) {
|
|
|
|
+ if (completion.isEmpty()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ candidates.add(new Candidate(completion));
|
2019-04-27 06:26:04 +00:00
|
|
|
}
|
|
|
|
- candidates.addAll(offers);
|
2017-06-09 17:05:12 +00:00
|
|
|
+ // Paper end
|
2019-04-27 06:26:04 +00:00
|
|
|
|
2017-06-09 17:05:12 +00:00
|
|
|
+ // Paper start - JLine handles cursor now
|
|
|
|
+ /*
|
|
|
|
final int lastSpace = buffer.lastIndexOf(' ');
|
|
|
|
if (lastSpace == -1) {
|
|
|
|
return cursor - buffer.length();
|
|
|
|
} else {
|
|
|
|
return cursor - (buffer.length() - lastSpace - 1);
|
|
|
|
}
|
|
|
|
+ */
|
|
|
|
+ // Paper end
|
|
|
|
} catch (ExecutionException e) {
|
|
|
|
- this.server.getLogger().log(Level.WARNING, "Unhandled exception when tab completing", e);
|
|
|
|
+ server.getLogger().log(Level.WARNING, "Unhandled exception when tab completing", e); // Paper - Remove "this."
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
Thread.currentThread().interrupt();
|
|
|
|
}
|
|
|
|
- return cursor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
2020-05-06 09:48:49 +00:00
|
|
|
index 70f8d42992aa348ef7b2d03d22cdd59d7c73f0fe..449e99d1b673870ed6892f6ab2c715a2db35c35d 100644
|
2017-06-09 17:05:12 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
2019-04-27 06:26:04 +00:00
|
|
|
@@ -17,7 +17,7 @@ public class ServerShutdownThread extends Thread {
|
|
|
|
server.close();
|
2017-06-09 17:05:12 +00:00
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
- server.reader.getTerminal().restore();
|
|
|
|
+ net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender
|
|
|
|
} catch (Exception e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java
|
2020-05-06 09:48:49 +00:00
|
|
|
index 99564fed7ce77e29dbdc591bcfe656af741acf8a..9a2da548b8860b496e396564b2c8f6383f020193 100644
|
2017-06-09 17:05:12 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java
|
2020-04-27 07:34:45 +00:00
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java
|
|
|
|
@@ -5,12 +5,12 @@ import java.io.IOException;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
2017-06-09 17:05:12 +00:00
|
|
|
-import jline.console.ConsoleReader;
|
2020-04-27 07:34:45 +00:00
|
|
|
+//import jline.console.ConsoleReader;
|
|
|
|
import org.bukkit.craftbukkit.Main;
|
2017-06-09 17:05:12 +00:00
|
|
|
-import org.fusesource.jansi.Ansi;
|
|
|
|
-import org.fusesource.jansi.Ansi.Erase;
|
2020-04-27 07:34:45 +00:00
|
|
|
+//import org.fusesource.jansi.Ansi;
|
|
|
|
+//import org.fusesource.jansi.Ansi.Erase;
|
|
|
|
|
2019-04-27 06:26:04 +00:00
|
|
|
-public class TerminalConsoleWriterThread extends Thread {
|
2020-04-27 07:34:45 +00:00
|
|
|
+public class TerminalConsoleWriterThread /*extends Thread*/ {/* // Paper - disable
|
|
|
|
private final ConsoleReader reader;
|
|
|
|
private final OutputStream output;
|
|
|
|
|
|
|
|
@@ -54,5 +54,5 @@ public class TerminalConsoleWriterThread extends Thread {
|
|
|
|
Logger.getLogger(TerminalConsoleWriterThread.class.getName()).log(Level.SEVERE, null, ex);
|
|
|
|
}
|
|
|
|
}
|
2017-06-09 17:05:12 +00:00
|
|
|
- }
|
2020-04-27 07:34:45 +00:00
|
|
|
+ }*/
|
|
|
|
}
|
2019-07-24 00:25:05 +00:00
|
|
|
diff --git a/src/main/resources/log4j2.component.properties b/src/main/resources/log4j2.component.properties
|
|
|
|
new file mode 100644
|
2020-05-06 09:48:49 +00:00
|
|
|
index 0000000000000000000000000000000000000000..0694b21465fb9e4164e71862ff24b62241b191f2
|
2019-07-24 00:25:05 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/resources/log4j2.component.properties
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+log4j.skipJansi=true
|
2017-06-09 17:05:12 +00:00
|
|
|
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
|
2020-05-06 09:48:49 +00:00
|
|
|
index 722ca84968cbbbdeffd09939abff0cccd0a84010..620b9490e5f159080e50289d127404a1b56adbef 100644
|
2017-06-09 17:05:12 +00:00
|
|
|
--- a/src/main/resources/log4j2.xml
|
|
|
|
+++ b/src/main/resources/log4j2.xml
|
2020-01-24 23:06:37 +00:00
|
|
|
@@ -1,17 +1,14 @@
|
2017-06-09 17:05:12 +00:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
2020-01-22 02:02:07 +00:00
|
|
|
<Configuration status="WARN" packages="com.mojang.util">
|
2017-06-09 17:05:12 +00:00
|
|
|
<Appenders>
|
2020-01-22 02:02:07 +00:00
|
|
|
- <Console name="SysOut" target="SYSTEM_OUT">
|
2019-04-27 06:26:04 +00:00
|
|
|
- <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
2020-01-22 02:02:07 +00:00
|
|
|
- </Console>
|
|
|
|
<Queue name="ServerGuiConsole">
|
|
|
|
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
|
|
|
|
</Queue>
|
2020-01-24 23:06:37 +00:00
|
|
|
- <Queue name="TerminalConsole">
|
|
|
|
- <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
|
|
|
- </Queue>
|
2017-06-09 17:05:12 +00:00
|
|
|
+ <TerminalConsole name="TerminalConsole">
|
|
|
|
+ <PatternLayout pattern="%highlightError{[%d{HH:mm:ss} %level]: %minecraftFormatting{%msg}%n%xEx}" />
|
|
|
|
+ </TerminalConsole>
|
|
|
|
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
|
|
|
|
- <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
|
|
|
+ <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %minecraftFormatting{%msg}{strip}%n" />
|
|
|
|
<Policies>
|
|
|
|
<TimeBasedTriggeringPolicy />
|
|
|
|
<OnStartupTriggeringPolicy />
|
2020-01-24 23:06:37 +00:00
|
|
|
@@ -24,10 +21,9 @@
|
2017-06-13 08:10:22 +00:00
|
|
|
<filters>
|
|
|
|
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
|
|
|
</filters>
|
2020-01-22 02:02:07 +00:00
|
|
|
- <AppenderRef ref="SysOut" level="info"/>
|
2017-06-13 08:10:22 +00:00
|
|
|
<AppenderRef ref="File"/>
|
2020-01-22 02:02:07 +00:00
|
|
|
- <AppenderRef ref="ServerGuiConsole" level="info"/>
|
2017-06-13 08:10:22 +00:00
|
|
|
<AppenderRef ref="TerminalConsole" level="info"/>
|
2020-01-22 02:02:07 +00:00
|
|
|
+ <AppenderRef ref="ServerGuiConsole" level="info"/>
|
2017-06-13 08:10:22 +00:00
|
|
|
</Root>
|
2020-01-22 02:02:07 +00:00
|
|
|
</Loggers>
|
|
|
|
</Configuration>
|