geforkt von Mirrors/Paper
Use TerminalConsoleAppender for console improvements
Rewrite console improvements (console colors, tab completion, persistent input line, ...) using JLine 3.x and TerminalConsoleAppender. 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. 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 Co-Authored-By: Emilia Kond <emilia@rymiel.space>
Dieser Commit ist enthalten in:
Ursprung
66779f5c86
Commit
36723cdd60
@ -5,6 +5,12 @@ plugins {
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
val log4jPlugins = sourceSets.create("log4jPlugins")
|
||||
configurations.named(log4jPlugins.compileClasspathConfigurationName) {
|
||||
extendsFrom(configurations.compileClasspath.get())
|
||||
}
|
||||
val alsoShade: Configuration by configurations.creating
|
||||
|
||||
// Paper start - configure mockito agent that is needed in newer java versions
|
||||
val mockitoAgent = configurations.register("mockitoAgent")
|
||||
abstract class MockitoAgentProvider : CommandLineArgumentProvider {
|
||||
@ -20,7 +26,22 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider {
|
||||
dependencies {
|
||||
implementation(project(":paper-api"))
|
||||
implementation("ca.spottedleaf:concurrentutil:0.0.2") // Paper - Add ConcurrentUtil dependency
|
||||
implementation("jline:jline:2.12.1")
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
|
||||
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
implementation("net.kyori:adventure-text-serializer-ansi:4.17.0") // Keep in sync with adventureVersion from Paper-API build file
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
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)
|
||||
// Paper end
|
||||
implementation("org.apache.logging.log4j:log4j-iostreams:2.24.1") // Paper - remove exclusion
|
||||
implementation("org.ow2.asm:asm-commons:9.7.1")
|
||||
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
|
||||
@ -93,6 +114,19 @@ tasks.check {
|
||||
dependsOn(scanJar)
|
||||
}
|
||||
// Paper end
|
||||
// Paper start - use TCA for console improvements
|
||||
tasks.serverJar {
|
||||
from(alsoShade.elements.map {
|
||||
it.map { f ->
|
||||
if (f.asFile.isFile) {
|
||||
zipTree(f.asFile)
|
||||
} else {
|
||||
f.asFile
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
// Paper end - use TCA for console improvements
|
||||
|
||||
tasks.test {
|
||||
include("**/**TestSuite.class")
|
||||
|
@ -49,7 +49,7 @@
|
||||
+import com.mojang.serialization.Lifecycle;
|
||||
+import java.io.File;
|
||||
+import java.util.Random;
|
||||
+import jline.console.ConsoleReader;
|
||||
+// import jline.console.ConsoleReader; // Paper
|
||||
+import joptsimple.OptionSet;
|
||||
+import net.minecraft.nbt.NbtException;
|
||||
+import net.minecraft.nbt.ReportedNbtException;
|
||||
@ -118,17 +118,15 @@
|
||||
private int playerIdleTimeout;
|
||||
private final long[] tickTimesNanos;
|
||||
private long aggregatedTickTimesNanos;
|
||||
@@ -276,6 +301,26 @@
|
||||
private static final AtomicReference<RuntimeException> fatalException = new AtomicReference();
|
||||
@@ -277,6 +302,25 @@
|
||||
private final SuppressedExceptionCollector suppressedExceptions;
|
||||
private final DiscontinuousFrame tickFrame;
|
||||
+
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public final WorldLoader.DataLoadContext worldLoader;
|
||||
+ public org.bukkit.craftbukkit.CraftServer server;
|
||||
+ public OptionSet options;
|
||||
+ public org.bukkit.command.ConsoleCommandSender console;
|
||||
+ public ConsoleReader reader;
|
||||
+ public static int currentTick = (int) (System.currentTimeMillis() / 50);
|
||||
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
||||
+ public int autosavePeriod;
|
||||
@ -142,10 +140,11 @@
|
||||
+ public final double[] recentTps = new double[ 3 ];
|
||||
+ // Spigot end
|
||||
+ public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
|
||||
|
||||
+
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
@@ -290,14 +335,14 @@
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -290,14 +334,14 @@
|
||||
thread.setPriority(8);
|
||||
}
|
||||
|
||||
@ -162,7 +161,7 @@
|
||||
super("Server");
|
||||
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
||||
this.onMetricsRecordingStopped = (methodprofilerresults) -> {
|
||||
@@ -319,36 +364,64 @@
|
||||
@@ -319,36 +363,68 @@
|
||||
this.scoreboard = new ServerScoreboard(this);
|
||||
this.customBossEvents = new CustomBossEvents();
|
||||
this.suppressedExceptions = new SuppressedExceptionCollector();
|
||||
@ -215,7 +214,9 @@
|
||||
+ this.options = options;
|
||||
+ this.worldLoader = worldLoader;
|
||||
+ this.vanillaCommandDispatcher = worldstem.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;
|
||||
@ -236,13 +237,15 @@
|
||||
+ MinecraftServer.LOGGER.warn((String) null, ex);
|
||||
+ }
|
||||
+ }
|
||||
+ */
|
||||
+ // Paper end
|
||||
+ Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
||||
+ // CraftBukkit end
|
||||
+ this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files
|
||||
}
|
||||
|
||||
private void readScoreboard(DimensionDataStorage persistentStateManager) {
|
||||
@@ -357,7 +430,7 @@
|
||||
@@ -357,7 +433,7 @@
|
||||
|
||||
protected abstract boolean initServer() throws IOException;
|
||||
|
||||
@ -251,7 +254,7 @@
|
||||
if (!JvmProfiler.INSTANCE.isRunning()) {
|
||||
;
|
||||
}
|
||||
@@ -365,12 +438,8 @@
|
||||
@@ -365,12 +441,8 @@
|
||||
boolean flag = false;
|
||||
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
|
||||
|
||||
@ -265,7 +268,7 @@
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish(true);
|
||||
}
|
||||
@@ -387,23 +456,217 @@
|
||||
@@ -387,23 +459,217 @@
|
||||
|
||||
protected void forceDifficulty() {}
|
||||
|
||||
@ -497,7 +500,7 @@
|
||||
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
try {
|
||||
@@ -427,30 +690,8 @@
|
||||
@@ -427,30 +693,8 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
}
|
||||
|
||||
@ -529,7 +532,7 @@
|
||||
|
||||
private static void setInitialSpawn(ServerLevel world, ServerLevelData worldProperties, boolean bonusChest, boolean debugWorld) {
|
||||
if (debugWorld) {
|
||||
@@ -458,6 +699,21 @@
|
||||
@@ -458,6 +702,21 @@
|
||||
} else {
|
||||
ServerChunkCache chunkproviderserver = world.getChunkSource();
|
||||
ChunkPos chunkcoordintpair = new ChunkPos(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||
@ -551,7 +554,7 @@
|
||||
int i = chunkproviderserver.getGenerator().getSpawnHeight(world);
|
||||
|
||||
if (i < world.getMinY()) {
|
||||
@@ -516,31 +772,36 @@
|
||||
@@ -516,31 +775,36 @@
|
||||
iworlddataserver.setGameType(GameType.SPECTATOR);
|
||||
}
|
||||
|
||||
@ -599,7 +602,7 @@
|
||||
ForcedChunksSavedData forcedchunk = (ForcedChunksSavedData) worldserver1.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -555,10 +816,17 @@
|
||||
@@ -555,10 +819,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -621,7 +624,7 @@
|
||||
}
|
||||
|
||||
public GameType getDefaultGameType() {
|
||||
@@ -588,12 +856,16 @@
|
||||
@@ -588,12 +859,16 @@
|
||||
worldserver.save((ProgressListener) null, flush, worldserver.noSave && !force);
|
||||
}
|
||||
|
||||
@ -640,7 +643,7 @@
|
||||
if (flush) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -628,18 +900,40 @@
|
||||
@@ -628,18 +903,40 @@
|
||||
this.stopServer();
|
||||
}
|
||||
|
||||
@ -681,7 +684,7 @@
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -693,6 +987,15 @@
|
||||
@@ -693,6 +990,15 @@
|
||||
} catch (IOException ioexception1) {
|
||||
MinecraftServer.LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), ioexception1);
|
||||
}
|
||||
@ -697,21 +700,23 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -720,6 +1023,13 @@
|
||||
|
||||
}
|
||||
@@ -717,8 +1023,15 @@
|
||||
MinecraftServer.LOGGER.error("Error while shutting down", interruptedexception);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ }
|
||||
|
||||
+ // Spigot Start
|
||||
+ private static double calcTps(double avg, double exp, double tps)
|
||||
+ {
|
||||
+ return ( avg * exp ) + ( tps * ( 1 - exp ) );
|
||||
+ }
|
||||
}
|
||||
+ // Spigot End
|
||||
+
|
||||
|
||||
protected void runServer() {
|
||||
try {
|
||||
if (!this.initServer()) {
|
||||
@@ -727,9 +1037,12 @@
|
||||
@@ -727,9 +1040,12 @@
|
||||
}
|
||||
|
||||
this.nextTickTimeNanos = Util.getNanos();
|
||||
@ -725,7 +730,7 @@
|
||||
while (this.running) {
|
||||
long i;
|
||||
|
||||
@@ -744,11 +1057,23 @@
|
||||
@@ -744,11 +1060,23 @@
|
||||
if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) {
|
||||
long k = j / i;
|
||||
|
||||
@ -749,7 +754,7 @@
|
||||
|
||||
boolean flag = i == 0L;
|
||||
|
||||
@@ -757,6 +1082,7 @@
|
||||
@@ -757,6 +1085,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
@ -757,21 +762,21 @@
|
||||
this.nextTickTimeNanos += i;
|
||||
|
||||
try {
|
||||
@@ -830,6 +1156,13 @@
|
||||
@@ -830,6 +1159,13 @@
|
||||
this.services.profileCache().clearExecutor();
|
||||
}
|
||||
|
||||
+ org.spigotmc.WatchdogThread.doStop(); // Spigot
|
||||
+ // CraftBukkit start - Restore terminal to original settings
|
||||
+ try {
|
||||
+ this.reader.getTerminal().restore();
|
||||
+ net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender
|
||||
+ } catch (Exception ignored) {
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -889,9 +1222,16 @@
|
||||
@@ -889,9 +1225,16 @@
|
||||
}
|
||||
|
||||
private boolean haveTime() {
|
||||
@ -789,7 +794,7 @@
|
||||
public static boolean throwIfFatalException() {
|
||||
RuntimeException runtimeexception = (RuntimeException) MinecraftServer.fatalException.get();
|
||||
|
||||
@@ -903,7 +1243,7 @@
|
||||
@@ -903,7 +1246,7 @@
|
||||
}
|
||||
|
||||
public static void setFatalException(RuntimeException exception) {
|
||||
@ -798,7 +803,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -977,7 +1317,7 @@
|
||||
@@ -977,7 +1320,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -807,7 +812,7 @@
|
||||
Profiler.get().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -1025,6 +1365,7 @@
|
||||
@@ -1025,6 +1368,7 @@
|
||||
}
|
||||
|
||||
public void tickServer(BooleanSupplier shouldKeepTicking) {
|
||||
@ -815,7 +820,7 @@
|
||||
long i = Util.getNanos();
|
||||
int j = this.pauseWhileEmptySeconds() * 20;
|
||||
|
||||
@@ -1041,11 +1382,13 @@
|
||||
@@ -1041,11 +1385,13 @@
|
||||
this.autoSave();
|
||||
}
|
||||
|
||||
@ -829,7 +834,7 @@
|
||||
++this.tickCount;
|
||||
this.tickRateManager.tick();
|
||||
this.tickChildren(shouldKeepTicking);
|
||||
@@ -1055,7 +1398,7 @@
|
||||
@@ -1055,7 +1401,7 @@
|
||||
}
|
||||
|
||||
--this.ticksUntilAutosave;
|
||||
@ -838,7 +843,7 @@
|
||||
this.autoSave();
|
||||
}
|
||||
|
||||
@@ -1071,10 +1414,13 @@
|
||||
@@ -1071,10 +1417,13 @@
|
||||
this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float) k / (float) TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F;
|
||||
this.logTickMethodTime(i);
|
||||
gameprofilerfiller.pop();
|
||||
@ -853,7 +858,7 @@
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
@@ -1082,6 +1428,7 @@
|
||||
@@ -1082,6 +1431,7 @@
|
||||
this.saveEverything(true, false, false);
|
||||
gameprofilerfiller.pop();
|
||||
MinecraftServer.LOGGER.debug("Autosave finished");
|
||||
@ -861,7 +866,7 @@
|
||||
}
|
||||
|
||||
private void logTickMethodTime(long tickStartTime) {
|
||||
@@ -1123,7 +1470,7 @@
|
||||
@@ -1123,7 +1473,7 @@
|
||||
private ServerStatus buildServerStatus() {
|
||||
ServerStatus.Players serverping_serverpingplayersample = this.buildPlayerStatus();
|
||||
|
||||
@ -870,7 +875,7 @@
|
||||
}
|
||||
|
||||
private ServerStatus.Players buildPlayerStatus() {
|
||||
@@ -1154,11 +1501,35 @@
|
||||
@@ -1154,11 +1504,35 @@
|
||||
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
|
||||
entityplayer.connection.suspendFlushing();
|
||||
});
|
||||
@ -906,7 +911,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||
|
||||
@@ -1167,16 +1538,20 @@
|
||||
@@ -1167,16 +1541,20 @@
|
||||
|
||||
return s + " " + String.valueOf(worldserver.dimension().location());
|
||||
});
|
||||
@ -927,7 +932,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
|
||||
|
||||
@@ -1189,18 +1564,24 @@
|
||||
@@ -1189,18 +1567,24 @@
|
||||
}
|
||||
|
||||
gameprofilerfiller.popPush("connection");
|
||||
@ -952,7 +957,7 @@
|
||||
|
||||
gameprofilerfiller.popPush("send chunks");
|
||||
iterator = this.playerList.getPlayers().iterator();
|
||||
@@ -1267,6 +1648,22 @@
|
||||
@@ -1267,6 +1651,22 @@
|
||||
return (ServerLevel) this.levels.get(key);
|
||||
}
|
||||
|
||||
@ -975,7 +980,7 @@
|
||||
public Set<ResourceKey<Level>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
}
|
||||
@@ -1296,7 +1693,7 @@
|
||||
@@ -1296,7 +1696,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@ -984,7 +989,16 @@
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
@@ -1481,10 +1878,20 @@
|
||||
@@ -1347,7 +1747,7 @@
|
||||
|
||||
@Override
|
||||
public void sendSystemMessage(Component message) {
|
||||
- MinecraftServer.LOGGER.info(message.getString());
|
||||
+ MinecraftServer.LOGGER.info(io.papermc.paper.adventure.PaperAdventure.ANSI_SERIALIZER.serialize(io.papermc.paper.adventure.PaperAdventure.asAdventure(message))); // Paper - Log message with colors
|
||||
}
|
||||
|
||||
public KeyPair getKeyPair() {
|
||||
@@ -1481,10 +1881,20 @@
|
||||
|
||||
@Override
|
||||
public String getMotd() {
|
||||
@ -1006,7 +1020,7 @@
|
||||
this.motd = motd;
|
||||
}
|
||||
|
||||
@@ -1507,7 +1914,7 @@
|
||||
@@ -1507,7 +1917,7 @@
|
||||
}
|
||||
|
||||
public ServerConnectionListener getConnection() {
|
||||
@ -1015,7 +1029,7 @@
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
@@ -1634,11 +2041,11 @@
|
||||
@@ -1634,11 +2044,11 @@
|
||||
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) {
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
@ -1029,7 +1043,7 @@
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
|
||||
List<Registry.PendingTags<?>> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess());
|
||||
@@ -1654,6 +2061,7 @@
|
||||
@@ -1654,6 +2064,7 @@
|
||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = minecraftserver_reloadableresources;
|
||||
@ -1037,7 +1051,7 @@
|
||||
this.packRepository.setSelected(dataPacks);
|
||||
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(MinecraftServer.getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures());
|
||||
|
||||
@@ -1952,7 +2360,7 @@
|
||||
@@ -1952,7 +2363,7 @@
|
||||
final List<String> list = Lists.newArrayList();
|
||||
final GameRules gamerules = this.getGameRules();
|
||||
|
||||
@ -1046,7 +1060,7 @@
|
||||
@Override
|
||||
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
|
||||
list.add(String.format(Locale.ROOT, "%s=%s\n", key.getId(), gamerules.getRule(key)));
|
||||
@@ -2058,7 +2466,7 @@
|
||||
@@ -2058,7 +2469,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
@ -1055,7 +1069,7 @@
|
||||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -2105,9 +2513,25 @@
|
||||
@@ -2105,9 +2516,25 @@
|
||||
if (bufferedwriter != null) {
|
||||
bufferedwriter.close();
|
||||
}
|
||||
@ -1081,7 +1095,7 @@
|
||||
private ProfilerFiller createProfiler() {
|
||||
if (this.willStartRecordingMetrics) {
|
||||
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||
@@ -2225,18 +2649,24 @@
|
||||
@@ -2225,18 +2652,24 @@
|
||||
}
|
||||
|
||||
public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) {
|
||||
|
@ -34,7 +34,7 @@
|
||||
@Nullable
|
||||
private RconThread rconThread;
|
||||
public DedicatedServerSettings settings;
|
||||
@@ -81,25 +93,58 @@
|
||||
@@ -81,33 +93,99 @@
|
||||
private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker;
|
||||
public ServerLinks serverLinks;
|
||||
|
||||
@ -63,6 +63,9 @@
|
||||
+ if (!org.bukkit.craftbukkit.Main.useConsole) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper start - Use TerminalConsoleAppender
|
||||
+ new com.destroystokyo.paper.console.PaperConsole(DedicatedServer.this).start();
|
||||
+ /*
|
||||
+ jline.console.ConsoleReader bufferedreader = DedicatedServer.this.reader;
|
||||
|
||||
+ // MC-33041, SPIGOT-5538: if System.in is not valid due to javaw, then return
|
||||
@ -96,13 +99,16 @@
|
||||
+ 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
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
||||
@@ -108,6 +153,29 @@
|
||||
}
|
||||
|
||||
+ */
|
||||
+ // Paper end
|
||||
}
|
||||
};
|
||||
|
||||
@ -114,6 +120,9 @@
|
||||
+ }
|
||||
+ 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) {
|
||||
@ -124,6 +133,8 @@
|
||||
+ TerminalConsoleWriterThread writerThread = new TerminalConsoleWriterThread(System.out, this.reader);
|
||||
+ this.reader.setCompletionHandler(new TerminalCompletionHandler(writerThread, this.reader.getCompletionHandler()));
|
||||
+ writerThread.start();
|
||||
+ */
|
||||
+ // Paper end - Not needed with TerminalConsoleAppender
|
||||
+
|
||||
+ System.setOut(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream());
|
||||
+ System.setErr(IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream());
|
||||
@ -132,7 +143,7 @@
|
||||
thread.setDaemon(true);
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
|
||||
thread.start();
|
||||
@@ -126,13 +194,22 @@
|
||||
@@ -126,13 +204,22 @@
|
||||
this.setPreventProxyConnections(dedicatedserverproperties.preventProxyConnections);
|
||||
this.setLocalIp(dedicatedserverproperties.serverIp);
|
||||
}
|
||||
@ -156,7 +167,7 @@
|
||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
@@ -156,10 +233,23 @@
|
||||
@@ -156,10 +243,23 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -181,7 +192,7 @@
|
||||
DedicatedServer.LOGGER.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
|
||||
}
|
||||
|
||||
@@ -170,7 +260,7 @@
|
||||
@@ -170,7 +270,7 @@
|
||||
if (!OldUsersConverter.serverReadyAfterUserconversion(this)) {
|
||||
return false;
|
||||
} else {
|
||||
@ -190,7 +201,7 @@
|
||||
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
||||
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
|
||||
long i = Util.getNanos();
|
||||
@@ -178,13 +268,13 @@
|
||||
@@ -178,13 +278,13 @@
|
||||
SkullBlockEntity.setup(this.services, this);
|
||||
GameProfileCache.setUsesAuthentication(this.usesAuthentication());
|
||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||
@ -206,7 +217,7 @@
|
||||
}
|
||||
|
||||
if (dedicatedserverproperties.enableQuery) {
|
||||
@@ -197,7 +287,7 @@
|
||||
@@ -197,7 +297,7 @@
|
||||
this.rconThread = RconThread.create(this);
|
||||
}
|
||||
|
||||
@ -215,7 +226,7 @@
|
||||
Thread thread1 = new Thread(new ServerWatchdog(this));
|
||||
|
||||
thread1.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandlerWithName(DedicatedServer.LOGGER));
|
||||
@@ -293,6 +383,7 @@
|
||||
@@ -293,6 +393,7 @@
|
||||
this.queryThreadGs4.stop();
|
||||
}
|
||||
|
||||
@ -223,7 +234,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,8 +393,8 @@
|
||||
@@ -302,8 +403,8 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -234,7 +245,7 @@
|
||||
}
|
||||
|
||||
public void handleConsoleInput(String command, CommandSourceStack commandSource) {
|
||||
@@ -311,12 +402,22 @@
|
||||
@@ -311,12 +412,22 @@
|
||||
}
|
||||
|
||||
public void handleConsoleInputs() {
|
||||
@ -258,7 +269,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -383,7 +484,7 @@
|
||||
@@ -383,7 +494,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isUnderSpawnProtection(ServerLevel world, BlockPos pos, Player player) {
|
||||
@ -267,7 +278,7 @@
|
||||
return false;
|
||||
} else if (this.getPlayerList().getOps().isEmpty()) {
|
||||
return false;
|
||||
@@ -541,16 +642,52 @@
|
||||
@@ -541,16 +652,52 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
@ -324,7 +335,7 @@
|
||||
}
|
||||
|
||||
public void storeUsingWhiteList(boolean useWhitelist) {
|
||||
@@ -660,4 +797,15 @@
|
||||
@@ -660,4 +807,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
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(() -> {
|
||||
|
@ -63,7 +63,7 @@
|
||||
public final PlayerDataStorage playerIo;
|
||||
private boolean doWhiteList;
|
||||
private final LayeredRegistryAccess<RegistryLayer> registries;
|
||||
@@ -134,13 +156,24 @@
|
||||
@@ -134,13 +156,23 @@
|
||||
private static final boolean ALLOW_LOGOUTIVATOR = false;
|
||||
private int sendAllPlayerInfoIn;
|
||||
|
||||
@ -73,8 +73,7 @@
|
||||
+
|
||||
public PlayerList(MinecraftServer server, LayeredRegistryAccess<RegistryLayer> 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);
|
||||
@ -90,7 +89,7 @@
|
||||
this.server = server;
|
||||
this.registries = registryManager;
|
||||
this.maxPlayers = maxPlayers;
|
||||
@@ -148,27 +181,37 @@
|
||||
@@ -148,27 +180,37 @@
|
||||
}
|
||||
|
||||
public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie clientData) {
|
||||
@ -133,7 +132,7 @@
|
||||
ServerLevel worldserver = this.server.getLevel(resourcekey);
|
||||
ServerLevel worldserver1;
|
||||
|
||||
@@ -182,10 +225,24 @@
|
||||
@@ -182,10 +224,24 @@
|
||||
player.setServerLevel(worldserver1);
|
||||
String s1 = connection.getLoggableAddress(this.server.logIPs());
|
||||
|
||||
@ -160,7 +159,7 @@
|
||||
ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, clientData);
|
||||
|
||||
connection.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection);
|
||||
@@ -194,7 +251,9 @@
|
||||
@@ -194,7 +250,9 @@
|
||||
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
|
||||
boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING);
|
||||
|
||||
@ -171,7 +170,7 @@
|
||||
playerconnection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
playerconnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities()));
|
||||
playerconnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().selected));
|
||||
@@ -213,8 +272,10 @@
|
||||
@@ -213,8 +271,10 @@
|
||||
} else {
|
||||
ichatmutablecomponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), s);
|
||||
}
|
||||
@ -183,7 +182,7 @@
|
||||
playerconnection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
||||
ServerStatus serverping = this.server.getStatus();
|
||||
|
||||
@@ -222,17 +283,70 @@
|
||||
@@ -222,17 +282,70 @@
|
||||
player.sendServerStatus(serverping);
|
||||
}
|
||||
|
||||
@ -258,7 +257,7 @@
|
||||
}
|
||||
|
||||
public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) {
|
||||
@@ -269,30 +383,31 @@
|
||||
@@ -269,30 +382,31 @@
|
||||
}
|
||||
|
||||
public void addWorldborderListener(ServerLevel world) {
|
||||
@ -295,7 +294,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -319,14 +434,15 @@
|
||||
@@ -319,14 +433,15 @@
|
||||
}
|
||||
|
||||
protected void save(ServerPlayer player) {
|
||||
@ -313,7 +312,7 @@
|
||||
|
||||
if (advancementdataplayer != null) {
|
||||
advancementdataplayer.save();
|
||||
@@ -334,95 +450,176 @@
|
||||
@@ -334,95 +449,176 @@
|
||||
|
||||
}
|
||||
|
||||
@ -528,7 +527,7 @@
|
||||
|
||||
if (entityplayer1 != null) {
|
||||
set.add(entityplayer1);
|
||||
@@ -431,30 +628,50 @@
|
||||
@@ -431,30 +627,50 @@
|
||||
Iterator iterator1 = set.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
@ -592,7 +591,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String s = (String) iterator.next();
|
||||
@@ -462,41 +679,88 @@
|
||||
@@ -462,41 +678,88 @@
|
||||
entityplayer1.addTag(s);
|
||||
}
|
||||
|
||||
@ -689,7 +688,7 @@
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
@@ -524,7 +788,18 @@
|
||||
@@ -524,7 +787,18 @@
|
||||
|
||||
public void tick() {
|
||||
if (++this.sendAllPlayerInfoIn > 600) {
|
||||
@ -709,7 +708,7 @@
|
||||
this.sendAllPlayerInfoIn = 0;
|
||||
}
|
||||
|
||||
@@ -541,6 +816,25 @@
|
||||
@@ -541,6 +815,25 @@
|
||||
|
||||
}
|
||||
|
||||
@ -735,7 +734,7 @@
|
||||
public void broadcastAll(Packet<?> packet, ResourceKey<Level> dimension) {
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
@@ -554,7 +848,7 @@
|
||||
@@ -554,7 +847,7 @@
|
||||
|
||||
}
|
||||
|
||||
@ -744,7 +743,7 @@
|
||||
PlayerTeam scoreboardteam = source.getTeam();
|
||||
|
||||
if (scoreboardteam != null) {
|
||||
@@ -573,7 +867,7 @@
|
||||
@@ -573,7 +866,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -753,7 +752,7 @@
|
||||
PlayerTeam scoreboardteam = source.getTeam();
|
||||
|
||||
if (scoreboardteam == null) {
|
||||
@@ -619,7 +913,7 @@
|
||||
@@ -619,7 +912,7 @@
|
||||
}
|
||||
|
||||
public void deop(GameProfile profile) {
|
||||
@ -762,7 +761,7 @@
|
||||
ServerPlayer entityplayer = this.getPlayer(profile.getId());
|
||||
|
||||
if (entityplayer != null) {
|
||||
@@ -643,6 +937,7 @@
|
||||
@@ -643,6 +936,7 @@
|
||||
player.connection.send(new ClientboundEntityEventPacket(player, b0));
|
||||
}
|
||||
|
||||
@ -770,7 +769,7 @@
|
||||
this.server.getCommands().sendCommands(player);
|
||||
}
|
||||
|
||||
@@ -656,23 +951,19 @@
|
||||
@@ -656,23 +950,19 @@
|
||||
|
||||
@Nullable
|
||||
public ServerPlayer getPlayerByName(String name) {
|
||||
@ -802,7 +801,7 @@
|
||||
if (entityplayer != player && entityplayer.level().dimension() == worldKey) {
|
||||
double d4 = x - entityplayer.getX();
|
||||
double d5 = y - entityplayer.getY();
|
||||
@@ -712,15 +1003,19 @@
|
||||
@@ -712,15 +1002,19 @@
|
||||
public void reloadWhiteList() {}
|
||||
|
||||
public void sendLevelInfo(ServerPlayer player, ServerLevel world) {
|
||||
@ -826,7 +825,7 @@
|
||||
}
|
||||
|
||||
player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F));
|
||||
@@ -729,8 +1024,16 @@
|
||||
@@ -729,8 +1023,16 @@
|
||||
|
||||
public void sendAllPlayerInfo(ServerPlayer player) {
|
||||
player.inventoryMenu.sendAllDataToRemote();
|
||||
@ -844,7 +843,7 @@
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
@@ -786,12 +1089,22 @@
|
||||
@@ -786,12 +1088,22 @@
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
@ -869,7 +868,7 @@
|
||||
public void broadcastSystemMessage(Component message, boolean overlay) {
|
||||
this.broadcastSystemMessage(message, (entityplayer) -> {
|
||||
return message;
|
||||
@@ -819,24 +1132,43 @@
|
||||
@@ -819,24 +1131,43 @@
|
||||
}
|
||||
|
||||
public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params) {
|
||||
@ -916,7 +915,7 @@
|
||||
}
|
||||
|
||||
if (flag1 && sender != null) {
|
||||
@@ -845,20 +1177,27 @@
|
||||
@@ -845,20 +1176,27 @@
|
||||
|
||||
}
|
||||
|
||||
@ -949,7 +948,7 @@
|
||||
Path path = file2.toPath();
|
||||
|
||||
if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
|
||||
@@ -867,7 +1206,7 @@
|
||||
@@ -867,7 +1205,7 @@
|
||||
}
|
||||
|
||||
serverstatisticmanager = new ServerStatsCounter(this.server, file1);
|
||||
@ -958,7 +957,7 @@
|
||||
}
|
||||
|
||||
return serverstatisticmanager;
|
||||
@@ -875,13 +1214,13 @@
|
||||
@@ -875,13 +1213,13 @@
|
||||
|
||||
public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) {
|
||||
UUID uuid = player.getUUID();
|
||||
@ -974,7 +973,7 @@
|
||||
}
|
||||
|
||||
advancementdataplayer.setPlayer(player);
|
||||
@@ -932,15 +1271,28 @@
|
||||
@@ -932,15 +1270,28 @@
|
||||
}
|
||||
|
||||
public void reloadResources() {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.destroystokyo.paper.console;
|
||||
|
||||
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;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.bukkit.craftbukkit.command.CraftConsoleCommandSender;
|
||||
|
||||
public class TerminalConsoleCommandSender extends CraftConsoleCommandSender {
|
||||
|
||||
private static final ComponentLogger LOGGER = ComponentLogger.logger(LogManager.getRootLogger().getName());
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String message) {
|
||||
final Component msg = LegacyComponentSerializer.legacySection().deserialize(message);
|
||||
this.sendMessage(Identity.nil(), msg, MessageType.SYSTEM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Identity identity, Component message, MessageType type) {
|
||||
LOGGER.info(message);
|
||||
}
|
||||
|
||||
}
|
@ -31,6 +31,7 @@ import net.kyori.adventure.text.flattener.ComponentFlattener;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
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;
|
||||
@ -129,6 +130,7 @@ public final class PaperAdventure {
|
||||
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();
|
||||
public static final Codec<Tag, String, CommandSyntaxException, RuntimeException> NBT_CODEC = new Codec<>() {
|
||||
@Override
|
||||
public @NotNull Tag decode(final @NotNull String encoded) throws CommandSyntaxException {
|
||||
|
@ -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;
|
||||
|
||||
@ -15,6 +17,6 @@ public class ComponentLoggerProviderImpl implements ComponentLoggerProvider {
|
||||
}
|
||||
|
||||
private String serialize(final Component message) {
|
||||
return PaperAdventure.asPlain(message, null);
|
||||
return PaperAdventure.ANSI_SERIALIZER.serialize(GlobalTranslator.render(message, Locale.getDefault()));
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.imageio.ImageIO;
|
||||
import jline.console.ConsoleReader;
|
||||
// import jline.console.ConsoleReader;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
@ -1359,9 +1359,13 @@ public final class CraftServer implements Server {
|
||||
return this.logger;
|
||||
}
|
||||
|
||||
// Paper start - JLine update
|
||||
/*
|
||||
public ConsoleReader getReader() {
|
||||
return this.console.reader;
|
||||
}
|
||||
*/
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
public PluginCommand getPluginCommand(String name) {
|
||||
|
@ -13,7 +13,6 @@ import java.util.logging.Logger;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.util.PathConverter;
|
||||
import org.fusesource.jansi.AnsiConsole;
|
||||
|
||||
public class Main {
|
||||
public static boolean useJline = true;
|
||||
@ -196,6 +195,8 @@ public class Main {
|
||||
}
|
||||
|
||||
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'});
|
||||
@ -213,9 +214,18 @@ public class Main {
|
||||
// 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(net.minecrell.terminalconsole.TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false");
|
||||
useJline = false;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
if (options.has("noconsole")) {
|
||||
Main.useConsole = false;
|
||||
useJline = false; // Paper
|
||||
System.setProperty(net.minecrell.terminalconsole.TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false"); // Paper
|
||||
}
|
||||
|
||||
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
|
||||
@ -231,6 +241,8 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
System.setProperty("library.jansi.version", "Paper"); // Paper - set meaningless jansi version to prevent git builds from crashing on Windows
|
||||
System.setProperty("jdk.console", "java.base"); // Paper - revert default console provider back to java.base so we can have our own jline
|
||||
System.out.println("Loading libraries, please wait...");
|
||||
net.minecraft.server.Main.main(options);
|
||||
} catch (Throwable t) {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -4,50 +4,73 @@ import java.util.Collections;
|
||||
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() {
|
||||
List<String> offers = ConsoleCommandCompleter.this.server.getCommandMap().tabComplete(ConsoleCommandCompleter.this.server.getConsoleSender(), buffer);
|
||||
List<String> offers = server.getCommandMap().tabComplete(server.getConsoleSender(), buffer); // Paper - Remove "this."
|
||||
|
||||
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 - Remove "this."
|
||||
server.getPluginManager().callEvent(tabEvent); // Paper - Remove "this."
|
||||
|
||||
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
|
||||
}
|
||||
candidates.addAll(offers);
|
||||
|
||||
// Paper start - JLine update
|
||||
for (String completion : offers) {
|
||||
if (completion.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
candidates.add(new Candidate(completion));
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class ServerShutdownThread extends Thread {
|
||||
this.server.close();
|
||||
} finally {
|
||||
try {
|
||||
this.server.reader.getTerminal().restore();
|
||||
net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
@ -4,14 +4,12 @@ import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import jline.console.ConsoleReader;
|
||||
import jline.console.completer.CompletionHandler;
|
||||
|
||||
/**
|
||||
* SPIGOT-6705: Make sure we print the display line again on tab completion, so that the user does not get stuck on it
|
||||
* e.g. The user needs to press y / n to continue
|
||||
*/
|
||||
public class TerminalCompletionHandler implements CompletionHandler {
|
||||
public class TerminalCompletionHandler /* implements CompletionHandler */ { /* Paper - comment out whole class
|
||||
|
||||
private final TerminalConsoleWriterThread writerThread;
|
||||
private final CompletionHandler delegate;
|
||||
@ -50,4 +48,5 @@ public class TerminalCompletionHandler implements CompletionHandler {
|
||||
|
||||
return result;
|
||||
}
|
||||
*/ // Paper end - comment out whole class
|
||||
}
|
||||
|
@ -7,13 +7,9 @@ import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import jline.console.ConsoleReader;
|
||||
import jline.console.completer.CandidateListCompletionHandler;
|
||||
import org.bukkit.craftbukkit.Main;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
import org.fusesource.jansi.Ansi.Erase;
|
||||
|
||||
public class TerminalConsoleWriterThread extends Thread {
|
||||
public class TerminalConsoleWriterThread /*extends Thread*/ {/* // Paper - Comment out entire class
|
||||
private final ResourceBundle bundle = ResourceBundle.getBundle(CandidateListCompletionHandler.class.getName(), Locale.getDefault());
|
||||
private final ConsoleReader reader;
|
||||
private final OutputStream output;
|
||||
@ -70,4 +66,5 @@ public class TerminalConsoleWriterThread extends Thread {
|
||||
void setCompletion(int completion) {
|
||||
this.completion = completion;
|
||||
}
|
||||
*/ // Paper - Comment out entire class
|
||||
}
|
||||
|
1
paper-server/src/main/resources/log4j2.component.properties
Normale Datei
1
paper-server/src/main/resources/log4j2.component.properties
Normale Datei
@ -0,0 +1 @@
|
||||
log4j.skipJansi=true
|
@ -1,17 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="SysOut" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n" />
|
||||
</Console>
|
||||
<Queue name="ServerGuiConsole">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg{nolookups}%n" />
|
||||
</Queue>
|
||||
<Queue name="TerminalConsole">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n" />
|
||||
</Queue>
|
||||
<TerminalConsole name="TerminalConsole">
|
||||
<PatternLayout pattern="%highlightError{[%d{HH:mm:ss} %level]: %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{nolookups}%n" />
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %stripAnsi{%msg}%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>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren