2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Minecrell <minecrell@minecrell.net>
|
|
|
|
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
|
|
|
|
|
2021-06-12 12:26:21 +02:00
|
|
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
2021-12-09 21:59:59 +01:00
|
|
|
index bba267ecca0121df22fdfa60961017863b5e3415..b9ed067f776a47a977e90bb89cdd1768fd54eb2c 100644
|
2021-06-12 12:26:21 +02:00
|
|
|
--- a/build.gradle.kts
|
|
|
|
+++ b/build.gradle.kts
|
2021-11-26 07:08:46 +01:00
|
|
|
@@ -12,7 +12,17 @@ repositories {
|
2021-06-12 12:26:21 +02:00
|
|
|
|
|
|
|
dependencies {
|
2021-11-26 07:08:46 +01:00
|
|
|
implementation(project(":paper-api"))
|
2021-06-12 12:26:21 +02:00
|
|
|
- implementation("jline:jline:2.12.1")
|
|
|
|
+ // Paper start
|
2021-11-02 19:02:16 +01:00
|
|
|
+ implementation("org.jline:jline-terminal-jansi:3.21.0")
|
|
|
|
+ implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
2021-06-12 12:26:21 +02:00
|
|
|
+ /*
|
2021-06-11 14:02:28 +02:00
|
|
|
+ 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.
|
2021-06-12 12:26:21 +02:00
|
|
|
+ */
|
|
|
|
+ runtimeOnly("org.apache.logging.log4j:log4j-core:2.14.1")
|
|
|
|
+ // Paper end
|
|
|
|
implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") // Paper
|
2021-08-13 19:08:34 +02:00
|
|
|
implementation("org.ow2.asm:asm:9.2")
|
2021-11-23 14:22:49 +01:00
|
|
|
implementation("org.ow2.asm:asm-commons:9.2") // Paper - ASM event executor generation
|
2021-06-11 14:02:28 +02: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
|
|
|
|
index 0000000000000000000000000000000000000000..a4070b59e261f0f1ac4beec47b11492f4724bf27
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
|
|
|
@@ -0,0 +1,41 @@
|
|
|
|
+package com.destroystokyo.paper.console;
|
|
|
|
+
|
|
|
|
+import net.minecraft.server.dedicated.DedicatedServer;
|
|
|
|
+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")
|
|
|
|
+ .variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
|
|
|
|
+ .completer(new ConsoleCommandCompleter(this.server))
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected boolean isRunning() {
|
|
|
|
+ return !this.server.isStopped() && this.server.isRunning();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void runCommand(String command) {
|
|
|
|
+ this.server.handleConsoleInput(command, this.server.createCommandSourceStack());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void shutdown() {
|
|
|
|
+ this.server.halt(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
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
|
|
|
|
index 0000000000000000000000000000000000000000..685deaa0e5d1ddc13e3a7c0471b1cfcf1710c869
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java
|
|
|
|
@@ -0,0 +1,17 @@
|
|
|
|
+package com.destroystokyo.paper.console;
|
|
|
|
+
|
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
|
+import org.apache.logging.log4j.Logger;
|
|
|
|
+import org.bukkit.craftbukkit.command.CraftConsoleCommandSender;
|
|
|
|
+
|
|
|
|
+public class TerminalConsoleCommandSender extends CraftConsoleCommandSender {
|
|
|
|
+
|
|
|
|
+ private static final Logger LOGGER = LogManager.getRootLogger();
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void sendRawMessage(String message) {
|
|
|
|
+ // TerminalConsoleAppender supports color codes directly in log messages
|
|
|
|
+ LOGGER.info(message);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2021-12-03 01:26:54 +01:00
|
|
|
index 0cf83ee46754197b2b639d07bff9a0d21566a641..123da97204af4bb40f98e09a5102227fb1359fd2 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2021-07-07 08:52:40 +02:00
|
|
|
@@ -9,6 +9,7 @@ import com.mojang.authlib.GameProfile;
|
|
|
|
import com.mojang.authlib.GameProfileRepository;
|
|
|
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
|
|
|
import com.mojang.datafixers.DataFixer;
|
2021-06-11 14:02:28 +02:00
|
|
|
+import io.papermc.paper.adventure.PaperAdventure; // Paper
|
|
|
|
import it.unimi.dsi.fastutil.longs.LongIterator;
|
|
|
|
import java.awt.image.BufferedImage;
|
2021-11-23 14:22:49 +01:00
|
|
|
import java.io.BufferedWriter;
|
|
|
|
@@ -167,7 +168,7 @@ import org.apache.logging.log4j.Logger;
|
|
|
|
// CraftBukkit start
|
2021-06-11 14:02:28 +02:00
|
|
|
import com.mojang.serialization.DynamicOps;
|
|
|
|
import com.mojang.serialization.Lifecycle;
|
|
|
|
-import jline.console.ConsoleReader;
|
|
|
|
+// import jline.console.ConsoleReader; // Paper
|
|
|
|
import joptsimple.OptionSet;
|
|
|
|
import net.minecraft.resources.RegistryReadOps;
|
|
|
|
import net.minecraft.server.bossevents.CustomBossEvents;
|
2021-12-03 01:26:54 +01:00
|
|
|
@@ -284,7 +285,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2021-06-11 14:02:28 +02: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
|
|
|
|
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
|
|
|
public int autosavePeriod;
|
2021-12-03 01:26:54 +01:00
|
|
|
@@ -368,7 +369,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2021-06-11 14:02:28 +02:00
|
|
|
this.datapackconfiguration = datapackconfiguration;
|
2021-12-03 01:26:54 +01:00
|
|
|
this.registryreadops = RegistryReadOps.createAndLoad(NbtOps.INSTANCE, datapackresources.getResourceManager(), iregistrycustom_dimension);
|
2021-06-11 14:02:28 +02:00
|
|
|
this.vanillaCommandDispatcher = datapackresources.commands; // CraftBukkit
|
|
|
|
+ // 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-12-03 01:26:54 +01:00
|
|
|
@@ -389,6 +392,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2021-06-12 12:26:21 +02:00
|
|
|
MinecraftServer.LOGGER.warn((String) null, ex);
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
+ */
|
|
|
|
+ // Paper end
|
|
|
|
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2021-12-03 01:26:54 +01:00
|
|
|
@@ -1175,7 +1180,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2021-06-11 14:02:28 +02:00
|
|
|
org.spigotmc.WatchdogThread.doStop(); // Spigot
|
|
|
|
// CraftBukkit start - Restore terminal to original settings
|
|
|
|
try {
|
2021-06-12 12:26:21 +02:00
|
|
|
- this.reader.getTerminal().restore();
|
2021-06-11 14:02:28 +02:00
|
|
|
+ net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2021-12-03 01:26:54 +01:00
|
|
|
@@ -1563,7 +1568,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
@Override
|
2021-06-12 12:26:21 +02:00
|
|
|
public void sendMessage(Component message, UUID sender) {
|
2021-06-11 14:02:28 +02:00
|
|
|
- MinecraftServer.LOGGER.info(message.getString());
|
|
|
|
+ MinecraftServer.LOGGER.info(PaperAdventure.LEGACY_SECTION_UXRC.serialize(PaperAdventure.asAdventure(message))); // Paper - Log message with colors
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyPair getKeyPair() {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
2021-11-23 14:22:49 +01:00
|
|
|
index 2201aeecd9936402825200dd696dc5607fe0f880..eed1d77a91f19722c2d2a3a43184565cd29732f7 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
2021-11-23 14:22:49 +01:00
|
|
|
@@ -107,6 +107,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2021-11-23 14:22:49 +01:00
|
|
|
@@ -138,7 +141,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
2021-06-11 14:02:28 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (s.trim().length() > 0) { // Trim to filter lines which are just spaces
|
|
|
|
- DedicatedServer.this.handleConsoleInput(s, DedicatedServer.this.createCommandSourceStack());
|
|
|
|
+ DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener());
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
}
|
2021-11-23 14:22:49 +01:00
|
|
|
@@ -146,6 +149,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
2021-06-11 14:02:28 +02:00
|
|
|
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ */
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-11-23 14:22:49 +01:00
|
|
|
@@ -157,6 +162,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
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) {
|
2021-11-23 14:22:49 +01:00
|
|
|
@@ -165,6 +173,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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-12-09 21:59:59 +01:00
|
|
|
index e47642c3164f7f7a358d2c7a9722643acf3e0089..dc891a463ec24b0b1b4c6c00b2c199e710204f61 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2021-11-23 14:22:49 +01:00
|
|
|
@@ -155,8 +155,7 @@ public abstract class PlayerList {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
public PlayerList(MinecraftServer server, RegistryAccess.RegistryHolder registryManager, PlayerDataStorage saveHandler, int maxPlayers) {
|
|
|
|
this.cserver = server.server = new CraftServer((DedicatedServer) server, this);
|
|
|
|
- server.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance();
|
|
|
|
- server.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(server.server));
|
|
|
|
+ server.console = new com.destroystokyo.paper.console.TerminalConsoleCommandSender(); // Paper
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
this.bans = new UserBanList(PlayerList.USERBANLIST_FILE);
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2021-12-03 01:26:54 +01:00
|
|
|
index 93e3d587f7d1d621e8aedb8e53f38a8df21b5587..8bad6fa590cfe47e1216a160531f4cd101c9450f 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2021-11-23 14:22:49 +01:00
|
|
|
@@ -48,7 +48,6 @@ import java.util.logging.Level;
|
2021-06-11 14:02:28 +02:00
|
|
|
import java.util.logging.Logger;
|
2021-11-23 14:22:49 +01:00
|
|
|
import java.util.stream.Collectors;
|
2021-06-11 14:02:28 +02:00
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
-import jline.console.ConsoleReader;
|
|
|
|
import net.minecraft.advancements.Advancement;
|
|
|
|
import net.minecraft.commands.CommandSourceStack;
|
|
|
|
import net.minecraft.commands.Commands;
|
2021-12-03 01:26:54 +01:00
|
|
|
@@ -60,6 +59,7 @@ import net.minecraft.resources.RegistryReadOps;
|
2021-06-11 14:02:28 +02:00
|
|
|
import net.minecraft.resources.ResourceKey;
|
|
|
|
import net.minecraft.resources.ResourceLocation;
|
|
|
|
import net.minecraft.server.ConsoleInput;
|
|
|
|
+//import jline.console.ConsoleReader; // Paper
|
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
import net.minecraft.server.bossevents.CustomBossEvent;
|
|
|
|
import net.minecraft.server.commands.ReloadCommand;
|
2021-12-03 01:26:54 +01:00
|
|
|
@@ -1287,9 +1287,13 @@ public final class CraftServer implements Server {
|
2021-06-12 12:26:21 +02:00
|
|
|
return this.logger;
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // 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-12-09 21:59:59 +01:00
|
|
|
index ed842f74fbd2de066cfbf8522c638ff2942e8197..8ab84e5591bbf2895f75b428f024760faa74d06d 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
|
|
@@ -12,7 +12,7 @@ import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
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;
|
2021-12-09 21:59:59 +01:00
|
|
|
@@ -197,6 +197,8 @@ public class Main {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
+ // Paper start - Handled by TerminalConsoleAppender
|
|
|
|
+ /*
|
|
|
|
// This trick bypasses Maven Shade's clever rewriting of our getProperty call when using String literals
|
|
|
|
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'});
|
2021-12-09 21:59:59 +01:00
|
|
|
@@ -214,9 +216,18 @@ public class Main {
|
2021-06-11 14:02:28 +02:00
|
|
|
// This ensures the terminal literal will always match the jline implementation
|
|
|
|
System.setProperty(jline.TerminalFactory.JLINE_TERMINAL, jline.UnsupportedTerminal.class.getName());
|
|
|
|
}
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ if (options.has("nojline")) {
|
|
|
|
+ System.setProperty(TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false");
|
|
|
|
+ useJline = false;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
if (options.has("noconsole")) {
|
2021-06-12 12:26:21 +02:00
|
|
|
Main.useConsole = false;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ useJline = false; // Paper
|
|
|
|
+ System.setProperty(TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false"); // Paper
|
|
|
|
}
|
|
|
|
|
2021-06-12 12:26:21 +02:00
|
|
|
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
|
2021-12-09 21:59:59 +01:00
|
|
|
@@ -244,7 +255,7 @@ public class Main {
|
2021-06-11 14:02:28 +02: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...");
|
|
|
|
net.minecraft.server.Main.main(options);
|
|
|
|
} catch (Throwable t) {
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
|
2021-06-12 12:26:21 +02:00
|
|
|
index 76fb1ecd47cb86b50486effe8cc7fe4abf8e311c..21f889ddec72b40f5954eec07417e08d192b4661 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
|
|
|
|
@@ -5,15 +5,13 @@ import java.util.EnumMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
-import jline.Terminal;
|
|
|
|
+//import jline.Terminal;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.ConsoleCommandSender;
|
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
|
|
-import org.fusesource.jansi.Ansi;
|
|
|
|
-import org.fusesource.jansi.Ansi.Attribute;
|
|
|
|
|
|
|
|
-public class ColouredConsoleSender extends CraftConsoleCommandSender {
|
|
|
|
+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();
|
|
|
|
@@ -93,5 +91,5 @@ public class ColouredConsoleSender extends CraftConsoleCommandSender {
|
|
|
|
} else {
|
|
|
|
return new ColouredConsoleSender();
|
|
|
|
}
|
|
|
|
- }
|
|
|
|
+ }*/ // Paper
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
|
2021-06-12 12:26:21 +02:00
|
|
|
index 0b4c62387c1093652ac15b64a8703249de4cf088..b996fde481cebbbcce80a6c267591136db7cc0bc 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
|
2021-06-12 12:26:21 +02:00
|
|
|
@@ -4,50 +4,73 @@ import java.util.Collections;
|
2021-06-11 14:02:28 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.logging.Level;
|
|
|
|
-import jline.console.completer.Completer;
|
|
|
|
+import net.minecraft.server.dedicated.DedicatedServer;
|
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
|
|
import org.bukkit.craftbukkit.util.Waitable;
|
|
|
|
+
|
|
|
|
+// 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
|
|
|
|
@Override
|
|
|
|
- public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) {
|
|
|
|
+ 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() {
|
2021-06-12 12:26:21 +02:00
|
|
|
- List<String> offers = ConsoleCommandCompleter.this.server.getCommandMap().tabComplete(ConsoleCommandCompleter.this.server.getConsoleSender(), buffer);
|
|
|
|
+ List<String> offers = server.getCommandMap().tabComplete(server.getConsoleSender(), buffer); // Paper - fix remap
|
|
|
|
|
|
|
|
- TabCompleteEvent tabEvent = new TabCompleteEvent(ConsoleCommandCompleter.this.server.getConsoleSender(), buffer, (offers == null) ? Collections.EMPTY_LIST : offers);
|
|
|
|
- ConsoleCommandCompleter.this.server.getPluginManager().callEvent(tabEvent);
|
|
|
|
+ TabCompleteEvent tabEvent = new TabCompleteEvent(server.getConsoleSender(), buffer, (offers == null) ? Collections.EMPTY_LIST : offers); // Paper - fix remap
|
|
|
|
+ server.getPluginManager().callEvent(tabEvent); // Paper - fix remap
|
|
|
|
|
2021-06-11 14:02:28 +02: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
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Paper start - JLine update
|
|
|
|
+ for (String completion : offers) {
|
|
|
|
+ if (completion.isEmpty()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ candidates.add(new Candidate(completion));
|
|
|
|
}
|
|
|
|
- candidates.addAll(offers);
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
+ // 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
|
2021-06-12 12:26:21 +02:00
|
|
|
index 6a073a9dc44d93eba296a0e18a9c7be8a7881725..b4a19d80bbf71591f25729fd0e98590350cb31d0 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
|
|
|
@@ -17,7 +17,7 @@ public class ServerShutdownThread extends Thread {
|
2021-06-12 12:26:21 +02:00
|
|
|
this.server.close();
|
2021-06-11 14:02:28 +02: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
|
2021-06-12 12:26:21 +02:00
|
|
|
index 5b63604aeae9a54e2c61cc4a22115a72f34a56bd..fc07f6bd45712ec0f1aec5fe820034e6d54b39c1 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java
|
|
|
|
+++ 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;
|
|
|
|
-import jline.console.ConsoleReader;
|
|
|
|
+//import jline.console.ConsoleReader;
|
|
|
|
import org.bukkit.craftbukkit.Main;
|
|
|
|
-import org.fusesource.jansi.Ansi;
|
|
|
|
-import org.fusesource.jansi.Ansi.Erase;
|
|
|
|
+//import org.fusesource.jansi.Ansi;
|
|
|
|
+//import org.fusesource.jansi.Ansi.Erase;
|
|
|
|
|
|
|
|
-public class TerminalConsoleWriterThread extends Thread {
|
|
|
|
+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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
- }
|
|
|
|
+ }*/
|
|
|
|
}
|
|
|
|
diff --git a/src/main/resources/log4j2.component.properties b/src/main/resources/log4j2.component.properties
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000000000000000000000000000000000000..0694b21465fb9e4164e71862ff24b62241b191f2
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/resources/log4j2.component.properties
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+log4j.skipJansi=true
|
|
|
|
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
|
|
|
|
index 722ca84968cbbbdeffd09939abff0cccd0a84010..620b9490e5f159080e50289d127404a1b56adbef 100644
|
|
|
|
--- a/src/main/resources/log4j2.xml
|
|
|
|
+++ b/src/main/resources/log4j2.xml
|
|
|
|
@@ -1,17 +1,14 @@
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<Configuration status="WARN" packages="com.mojang.util">
|
|
|
|
<Appenders>
|
|
|
|
- <Console name="SysOut" target="SYSTEM_OUT">
|
|
|
|
- <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
|
|
|
- </Console>
|
|
|
|
<Queue name="ServerGuiConsole">
|
|
|
|
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
|
|
|
|
</Queue>
|
|
|
|
- <Queue name="TerminalConsole">
|
|
|
|
- <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
|
|
|
- </Queue>
|
|
|
|
+ <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 />
|
|
|
|
@@ -24,10 +21,9 @@
|
|
|
|
<filters>
|
|
|
|
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
|
|
|
</filters>
|
|
|
|
- <AppenderRef ref="SysOut" level="info"/>
|
|
|
|
<AppenderRef ref="File"/>
|
|
|
|
- <AppenderRef ref="ServerGuiConsole" level="info"/>
|
|
|
|
<AppenderRef ref="TerminalConsole" level="info"/>
|
|
|
|
+ <AppenderRef ref="ServerGuiConsole" level="info"/>
|
|
|
|
</Root>
|
|
|
|
</Loggers>
|
|
|
|
</Configuration>
|