Paper/Spigot-Server-Patches/0349-Fix-CraftServer-isPrimaryThread-and-MinecraftServer-.patch
Jason 750049fa2b
Fix incorrect colors in some log messages (#5609)
CraftChatMessage.fromComponent fails to take into account the style of TranslatableComponent args, causing any styling on args to be completely ignored.

Fixing this is relatively simple, however would cause behavior to deviate from upstream. This commit will fix the coloring in messages logged through MinecraftServer.LOGGER by simply using Adventure's legacy text serializer, which properly serializes TranslatableComponents and their arguments. Note that this doesn't do anything about the underlying issue of CraftChatMessage.fromComponent improperly serializing TranslatableComponents.
2021-05-10 20:47:51 -07:00

44 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 13 May 2019 21:10:59 -0700
Subject: [PATCH] Fix CraftServer#isPrimaryThread and MinecraftServer
isMainThread
md_5 changed it so he could shut down the server asynchronously
from watchdog, although we have patches that prevent that type
of behavior for this exact reason.
md_5 also placed code in PlayerConnectionUtils that would have
solved https://bugs.mojang.com/browse/MC-142590, making the change
to MinecraftServer#isMainThread irrelevant.
By reverting his change to MinecraftServer#isMainThread packet
handling that should have been handled synchronously will be handled
synchronously when the server gets shut down.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 7ef01f2f80eea31fa76d22c3a0d5036883dee516..e885e5c4c772a87c0359ed2c56aa71a856c3be59 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2192,7 +2192,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// CraftBukkit start
@Override
public boolean isMainThread() {
- return super.isMainThread() || this.isStopped(); // CraftBukkit - MC-142590
+ return super.isMainThread() /*|| this.isStopped()*/; // CraftBukkit - MC-142590 // Paper - causes issues elsewhere
}
public boolean isDebugging() {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c1e563b76271ad84654fe2abf31f86815600dca6..841443e8dc9e72296d364fa61f8778d7c24038c9 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1833,7 +1833,7 @@ public final class CraftServer implements Server {
@Override
public boolean isPrimaryThread() {
- return Thread.currentThread().equals(console.serverThread) || console.hasStopped() || !org.spigotmc.AsyncCatcher.enabled; // All bets are off if we have shut down (e.g. due to watchdog)
+ return Thread.currentThread().equals(console.serverThread); // Paper - Fix issues with detecting main thread properly
}
// Paper start