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.
2023-06-13 00:00:12 +02:00
Also uses the new ANSIComponentSerializer to serialize components when
logging them via the ComponentLogger, or when sending messages to the
console, for hex color support.
2021-06-11 14:02:28 +02:00
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
2023-06-13 00:00:12 +02:00
Co-Authored-By: Emilia Kond <emilia@rymiel.space>
2021-06-12 12:26:21 +02:00
diff --git a/build.gradle.kts b/build.gradle.kts
2024-04-05 02:12:05 +02:00
index 1219b12750edb855df0962d14d7f3c1859d78b2e..511dfff4870c197b6f69169cc0504ef05988bb9c 100644
2021-06-12 12:26:21 +02:00
--- a/build.gradle.kts
+++ b/build.gradle.kts
2023-07-02 07:00:46 +02:00
@@ -6,9 +6,30 @@ plugins {
id("com.github.johnrengelman.shadow")
}
2021-06-12 12:26:21 +02:00
2023-07-02 07:00:46 +02:00
+val log4jPlugins = sourceSets.create("log4jPlugins")
+configurations.named(log4jPlugins.compileClasspathConfigurationName) {
+ extendsFrom(configurations.compileClasspath.get())
+}
+val alsoShade: Configuration by configurations.creating
+
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")
2023-06-13 01:44:07 +02:00
+ implementation("net.kyori:adventure-text-serializer-ansi:4.14.0") // Keep in sync with adventureVersion from Paper-API build file
2023-08-04 23:54:25 +02:00
+ implementation("net.kyori:ansi:1.0.3") // Manually bump beyond above transitive dep
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
+ */
2023-07-02 07:00:46 +02:00
+ runtimeOnly("org.apache.logging.log4j:log4j-core:2.19.0")
+ log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - Needed to generate meta for our Log4j plugins
+ runtimeOnly(log4jPlugins.output)
+ alsoShade(log4jPlugins.output)
2021-06-12 12:26:21 +02:00
+ // Paper end
2022-12-07 19:52:24 +01:00
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
2024-04-06 21:53:39 +02:00
implementation("org.ow2.asm:asm-commons:9.7")
2024-01-14 10:46:04 +01:00
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
2024-04-05 02:12:05 +02:00
@@ -75,7 +96,7 @@ relocation {
2023-07-02 07:00:46 +02:00
}
tasks.shadowJar {
- configurations = listOf(project.configurations.vanillaServer.get())
+ configurations = listOf(project.configurations.vanillaServer.get(), alsoShade)
archiveClassifier.set("mojang-mapped")
for (relocation in relocation.relocations.get()) {
diff --git a/src/log4jPlugins/java/io/papermc/paper/console/StripANSIConverter.java b/src/log4jPlugins/java/io/papermc/paper/console/StripANSIConverter.java
new file mode 100644
index 0000000000000000000000000000000000000000..91547f6e6fe90006713beb2818da634304bdd236
--- /dev/null
+++ b/src/log4jPlugins/java/io/papermc/paper/console/StripANSIConverter.java
@@ -0,0 +1,51 @@
+package io.papermc.paper.console;
+
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.layout.PatternLayout;
+import org.apache.logging.log4j.core.pattern.ConverterKeys;
+import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
+import org.apache.logging.log4j.core.pattern.PatternConverter;
+import org.apache.logging.log4j.core.pattern.PatternFormatter;
+import org.apache.logging.log4j.core.pattern.PatternParser;
+
+import java.util.List;
+import java.util.regex.Pattern;
+
+@Plugin(name = "stripAnsi", category = PatternConverter.CATEGORY)
+@ConverterKeys({"stripAnsi"})
+public final class StripANSIConverter extends LogEventPatternConverter {
+ final private Pattern ANSI_PATTERN = Pattern.compile("\\e\\[[\\d;]*[^\\d;]");
+
+ private final List<PatternFormatter> formatters;
+
+ private StripANSIConverter(List<PatternFormatter> formatters) {
+ super("stripAnsi", null);
+ this.formatters = formatters;
+ }
+
+ @Override
+ public void format(LogEvent event, StringBuilder toAppendTo) {
+ int start = toAppendTo.length();
+ for (PatternFormatter formatter : formatters) {
+ formatter.format(event, toAppendTo);
+ }
+ String content = toAppendTo.substring(start);
+ content = ANSI_PATTERN.matcher(content).replaceAll("");
+
+ toAppendTo.setLength(start);
+ toAppendTo.append(content);
+ }
+
+ public static StripANSIConverter newInstance(Configuration config, String[] options) {
+ if (options.length != 1) {
+ LOGGER.error("Incorrect number of options on stripAnsi. Expected exactly 1, received " + options.length);
+ return null;
+ }
+
+ PatternParser parser = PatternLayout.createPatternParser(config);
+ List<PatternFormatter> formatters = parser.parse(options[0]);
+ return new StripANSIConverter(formatters);
+ }
+}
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
2023-06-13 00:00:12 +02:00
index 0000000000000000000000000000000000000000..8f07539a82f449ad217e316a7513a1708781fb63
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java
2023-06-13 00:00:12 +02:00
@@ -0,0 +1,26 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.console;
+
2023-06-13 00:00:12 +02:00
+import net.kyori.adventure.audience.MessageType;
+import net.kyori.adventure.identity.Identity;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
2021-06-11 14:02:28 +02:00
+import org.apache.logging.log4j.LogManager;
+import org.bukkit.craftbukkit.command.CraftConsoleCommandSender;
+
+public class TerminalConsoleCommandSender extends CraftConsoleCommandSender {
+
2023-06-13 00:00:12 +02:00
+ private static final ComponentLogger LOGGER = ComponentLogger.logger(LogManager.getRootLogger().getName());
2021-06-11 14:02:28 +02:00
+
+ @Override
+ public void sendRawMessage(String message) {
2023-06-13 00:00:12 +02:00
+ final Component msg = LegacyComponentSerializer.legacySection().deserialize(message);
+ this.sendMessage(Identity.nil(), msg, MessageType.SYSTEM);
+ }
+
+ @Override
+ public void sendMessage(Identity identity, Component message, MessageType type) {
2021-06-11 14:02:28 +02:00
+ LOGGER.info(message);
+ }
+
+}
2023-06-13 00:00:12 +02:00
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
2024-02-17 21:22:00 +01:00
index 032d23ecda574ed1a3c740c16d13055f399bd6c4..cf5a4c142ed6d9ab4850373a9041bdc6af5a2a71 100644
2023-06-13 00:00:12 +02:00
--- a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
2024-02-17 21:22:00 +01:00
@@ -25,6 +25,7 @@ import net.kyori.adventure.text.flattener.ComponentFlattener;
import net.kyori.adventure.text.format.Style;
2023-06-13 00:00:12 +02:00
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.serializer.ComponentSerializer;
+import net.kyori.adventure.text.serializer.ansi.ANSIComponentSerializer;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
2024-02-17 21:22:00 +01:00
@@ -113,6 +114,7 @@ public final class PaperAdventure {
2023-06-13 00:00:12 +02:00
public static final AttributeKey<Locale> LOCALE_ATTRIBUTE = AttributeKey.valueOf("adventure:locale"); // init after FLATTENER because classloading triggered here might create a logger
@Deprecated
public static final PlainComponentSerializer PLAIN = PlainComponentSerializer.builder().flattener(FLATTENER).build();
+ public static final ANSIComponentSerializer ANSI_SERIALIZER = ANSIComponentSerializer.builder().flattener(FLATTENER).build();
2023-12-12 07:02:06 +01:00
static final Codec<CompoundTag, String, IOException, IOException> NBT_CODEC = new Codec<CompoundTag, String, IOException, IOException>() {
2023-06-13 00:00:12 +02:00
@Override
public @NotNull CompoundTag decode(final @NotNull String encoded) throws IOException {
diff --git a/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java
2023-12-25 11:51:44 +01:00
index 8323f135d6bf2e1f12525e05094ffa3f2420e7e1..a143ea1e58464a3122fbd8ccafe417bdb3c31c78 100644
2023-06-13 00:00:12 +02:00
--- a/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java
+++ b/src/main/java/io/papermc/paper/adventure/providers/ComponentLoggerProviderImpl.java
@@ -1,9 +1,11 @@
package io.papermc.paper.adventure.providers;
import io.papermc.paper.adventure.PaperAdventure;
+import java.util.Locale;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
import net.kyori.adventure.text.logger.slf4j.ComponentLoggerProvider;
+import net.kyori.adventure.translation.GlobalTranslator;
import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory;
2023-12-25 11:51:44 +01:00
@@ -15,6 +17,6 @@ public class ComponentLoggerProviderImpl implements ComponentLoggerProvider {
2023-06-13 00:00:12 +02:00
}
private String serialize(final Component message) {
- return PaperAdventure.asPlain(message, null);
+ return PaperAdventure.ANSI_SERIALIZER.serialize(GlobalTranslator.render(message, Locale.getDefault()));
}
}
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
2024-04-06 21:53:39 +02:00
index 48513e585ce02c301983adbe1224e95ff7f9a345..22b9d4bebee30877225b08b46cec6084b12a9c5a 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
2023-12-05 22:34:01 +01:00
@@ -155,7 +155,7 @@ import org.slf4j.Logger;
import com.mojang.serialization.Dynamic;
2021-06-11 14:02:28 +02:00
import com.mojang.serialization.Lifecycle;
2022-06-07 22:12:48 +02:00
import java.util.Random;
2022-06-07 22:43:05 +02:00
-import jline.console.ConsoleReader;
2021-06-11 14:02:28 +02:00
+// import jline.console.ConsoleReader; // Paper
import joptsimple.OptionSet;
2023-12-05 22:34:01 +01:00
import net.minecraft.nbt.NbtException;
import net.minecraft.nbt.ReportedNbtException;
2024-01-24 11:45:17 +01:00
@@ -284,7 +284,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
2023-08-28 13:05:48 +02:00
public org.bukkit.craftbukkit.CraftServer server;
2021-06-11 14:02:28 +02:00
public OptionSet options;
public org.bukkit.command.ConsoleCommandSender console;
- public ConsoleReader reader;
2024-01-25 10:54:46 +01:00
public static int currentTick; // Paper - improve tick loop
2021-06-11 14:02:28 +02:00
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
public int autosavePeriod;
2024-01-25 10:54:46 +01:00
@@ -371,7 +370,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
2022-12-07 19:52:24 +01:00
this.options = options;
this.worldLoader = worldLoader;
2022-03-01 06:43:03 +01:00
this.vanillaCommandDispatcher = worldstem.dataPackResources().commands; // CraftBukkit
2021-06-11 14:02:28 +02: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;
2024-01-25 10:54:46 +01:00
@@ -392,6 +393,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));
2023-09-21 22:35:39 +02:00
// CraftBukkit end
2024-01-13 21:31:02 +01:00
this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files
2024-01-25 10:54:46 +01:00
@@ -1187,7 +1190,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
2024-01-25 10:54:46 +01:00
@@ -1685,7 +1688,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
2021-06-11 14:02:28 +02:00
@Override
2022-06-07 22:12:48 +02:00
public void sendSystemMessage(Component message) {
2021-06-11 14:02:28 +02:00
- MinecraftServer.LOGGER.info(message.getString());
2023-06-13 00:00:12 +02:00
+ MinecraftServer.LOGGER.info(io.papermc.paper.adventure.PaperAdventure.ANSI_SERIALIZER.serialize(io.papermc.paper.adventure.PaperAdventure.asAdventure(message))); // Paper - Log message with colors
2021-06-11 14:02:28 +02:00
}
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
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
index c8163a8645248765c0fa6c15bc8c37facdc70dc7..8edf2f049aa077792bfb507384f4cf5bb716cb64 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
2022-12-07 19:52:24 +01:00
@@ -98,6 +98,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();
+ /*
2023-10-27 01:34:58 +02:00
jline.console.ConsoleReader bufferedreader = DedicatedServer.this.reader;
2021-06-11 14:02:28 +02:00
// MC-33041, SPIGOT-5538: if System.in is not valid due to javaw, then return
2022-12-07 19:52:24 +01:00
@@ -129,7 +132,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
}
2022-12-07 19:52:24 +01:00
@@ -137,6 +140,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
}
};
2022-12-07 19:52:24 +01:00
@@ -148,6 +153,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) {
2022-12-07 19:52:24 +01:00
@@ -156,6 +164,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());
2023-06-13 00:00:12 +02:00
diff --git a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
index 75083eeb9b413e6dd5375007360dce6857a08fff..d292fdb165436f0b9b46b32110f5e09ad0e517a1 100644
--- a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
+++ b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java
@@ -166,7 +166,7 @@ public class MinecraftServerGui extends JComponent {
this.finalizers.forEach(Runnable::run);
}
- private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})*)?[m|K]"); // CraftBukkit
+ private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\e\\[[\\d;]*[^\\d;]"); // CraftBukkit // Paper
public void print(JTextArea textArea, JScrollPane scrollPane, String message) {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(() -> {
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
index 1c313dbfc501ce5782fb2d7500b9af35f0855c46..e35e202d49f01c0c97b8c3e41a14254cbd4f2c49 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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -161,8 +161,7 @@ public abstract class PlayerList {
2021-06-11 14:02:28 +02:00
2022-12-07 19:52:24 +01:00
public PlayerList(MinecraftServer server, LayeredRegistryAccess<RegistryLayer> registryManager, PlayerDataStorage saveHandler, int maxPlayers) {
2021-06-11 14:02:28 +02:00
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
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
index 827579f59d34b61912a67b40624f0f41524185fd..f7d937c6a11e24afe767411428210f3c042a6f78 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
Updated Upstream (Bukkit/CraftBukkit) (#10034)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
@@ -42,7 +42,7 @@ 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;
2023-11-11 21:25:45 +01:00
+// import jline.console.ConsoleReader;
2023-09-21 22:35:39 +02:00
import net.minecraft.advancements.AdvancementHolder;
2021-06-11 14:02:28 +02:00
import net.minecraft.commands.CommandSourceStack;
2023-11-11 21:25:45 +01:00
import net.minecraft.commands.Commands;
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
@@ -1341,9 +1341,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() {
2023-10-27 01:34:58 +02:00
return this.console.reader;
2021-06-11 14:02:28 +02:00
}
+ */
+ // 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
2024-04-05 02:12:05 +02:00
index adae906894144a1684a0dab15226649fd4bf6354..1bd54fbadc9b1b5207325c78298cc72f61455ac7 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
2023-03-14 19:36:39 +01:00
@@ -13,7 +13,6 @@ import java.util.logging.Logger;
2021-06-11 14:02:28 +02:00
import joptsimple.OptionParser;
import joptsimple.OptionSet;
2023-03-14 19:36:39 +01:00
import joptsimple.util.PathConverter;
2021-06-11 14:02:28 +02:00
-import org.fusesource.jansi.AnsiConsole;
public class Main {
public static boolean useJline = true;
2023-11-25 10:49:48 +01:00
@@ -220,6 +219,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'});
2023-11-25 10:49:48 +01:00
@@ -237,9 +238,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")) {
2023-03-14 19:36:39 +01:00
+ System.setProperty(net.minecrell.terminalconsole.TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false");
2021-06-11 14:02:28 +02:00
+ 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
2023-03-14 19:36:39 +01:00
+ System.setProperty(net.minecrell.terminalconsole.TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false"); // Paper
2021-06-11 14:02:28 +02:00
}
2022-07-29 09:11:11 +02:00
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
2024-01-24 11:45:17 +01:00
@@ -268,6 +278,7 @@ public class Main {
2021-06-11 14:02:28 +02:00
}
2024-01-24 11:45:17 +01:00
// Paper end - Log Java and OS versioning to help with debugging plugin issues
+ System.setProperty("library.jansi.version", "Paper"); // Paper - set meaningless jansi version to prevent git builds from crashing on Windows
2021-06-11 14:02:28 +02:00
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
2023-10-27 01:34:58 +02:00
index bcf1c36d07b79520a39643d3a01020a67b1c9ef2..217e7e3b9db04c7fc5f6518f39cc9d3488f9128d 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
2023-10-27 01:34:58 +02:00
index 0b4c62387c1093652ac15b64a8703249de4cf088..d24acf28f5ed023acc550bcf877e4b9800ec8c9f 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);
2023-10-27 01:34:58 +02:00
+ List<String> offers = server.getCommandMap().tabComplete(server.getConsoleSender(), buffer); // Paper - Remove "this."
2021-06-12 12:26:21 +02:00
- TabCompleteEvent tabEvent = new TabCompleteEvent(ConsoleCommandCompleter.this.server.getConsoleSender(), buffer, (offers == null) ? Collections.EMPTY_LIST : offers);
- ConsoleCommandCompleter.this.server.getPluginManager().callEvent(tabEvent);
2023-10-27 01:34:58 +02:00
+ TabCompleteEvent tabEvent = new TabCompleteEvent(server.getConsoleSender(), buffer, (offers == null) ? Collections.EMPTY_LIST : offers); // Paper - Remove "this."
+ server.getPluginManager().callEvent(tabEvent); // Paper - Remove "this."
2021-06-12 12:26:21 +02:00
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
2023-03-23 22:57:03 +01:00
+ }
+
2021-06-11 14:02:28 +02:00
+ // Paper start - JLine update
+ for (String completion : offers) {
+ if (completion.isEmpty()) {
+ continue;
+ }
+
+ candidates.add(new Candidate(completion));
2023-03-23 22:57:03 +01:00
}
- candidates.addAll(offers);
2021-06-11 14:02:28 +02:00
+ // Paper end
2023-03-23 22:57:03 +01:00
2021-06-11 14:02:28 +02: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
2023-10-27 01:34:58 +02:00
index 8390f5b5b957b5435efece26507a89756d0a7b3c..c6e8441e299f477ddb22c1ce2618710763978f1a 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
2023-09-17 00:54:33 +02:00
@@ -16,7 +16,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 {
2023-10-27 01:34:58 +02:00
- this.server.reader.getTerminal().restore();
2021-06-11 14:02:28 +02:00
+ 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
2022-03-01 06:43:03 +01:00
index 1d8b279f3cbe6fde6bb1bfc4985c4133b0d4a95d..cdc52bbe5c6ae4688615a7732b10071f7f51718e 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
2023-06-13 00:00:12 +02:00
index 722ca84968cbbbdeffd09939abff0cccd0a84010..a994ec0f8621b1f267b40049306f63479c050e2f 100644
2021-06-11 14:02:28 +02:00
--- 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">
2023-06-13 00:00:12 +02:00
+ <PatternLayout pattern="%highlightError{[%d{HH:mm:ss} %level]: %msg%n%xEx}" />
2021-06-11 14:02:28 +02:00
+ </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" />
2023-06-13 00:00:12 +02:00
+ <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %stripAnsi{%msg}%n" />
2021-06-11 14:02:28 +02:00
<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>