From 4fdda9e583358fa85644dc9903dfd7496d106e2c Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:02:22 +0100 Subject: [PATCH] Keep newlines in outdated client/server message (#10042) --- ...ors-not-working-in-some-kick-messages.patch | 18 +++++++++++------- .../server/0565-Add-bypass-host-check.patch | 4 ++-- .../0596-Add-Unix-domain-socket-support.patch | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/patches/server/0449-Fix-hex-colors-not-working-in-some-kick-messages.patch b/patches/server/0449-Fix-hex-colors-not-working-in-some-kick-messages.patch index e1a897c3f..95c8bad34 100644 --- a/patches/server/0449-Fix-hex-colors-not-working-in-some-kick-messages.patch +++ b/patches/server/0449-Fix-hex-colors-not-working-in-some-kick-messages.patch @@ -5,27 +5,31 @@ Subject: [PATCH] Fix hex colors not working in some kick messages diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -index 21aafb1ea51769659462d722aa318460b37cbc1c..ea4a7186b707e471d5f3972d21502b7a316e0d55 100644 +index 21aafb1ea51769659462d722aa318460b37cbc1c..5d7f092e966d5b0496f48bd5c9d274157ac6d250 100644 --- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -@@ -77,12 +77,12 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL +@@ -77,14 +77,16 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL } // CraftBukkit end if (packet.protocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) { - MutableComponent ichatmutablecomponent; -+ Component ichatmutablecomponent; // Paper - Fix hex colors not working in some kick messages ++ net.kyori.adventure.text.Component adventureComponent; // Paper - Fix hex colors not working in some kick messages if (packet.protocolVersion() < SharedConstants.getCurrentVersion().getProtocolVersion()) { // Spigot - SPIGOT-7546: Handle version check correctly for outdated client message - ichatmutablecomponent = Component.literal( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) ); // Spigot -+ ichatmutablecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages ++ adventureComponent = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(java.text.MessageFormat.format(org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName())); // Spigot // Paper - Fix hex colors not working in some kick messages } else { - ichatmutablecomponent = Component.literal( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) ); // Spigot -+ ichatmutablecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages ++ adventureComponent = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(java.text.MessageFormat.format(org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName())); // Spigot // Paper - Fix hex colors not working in some kick messages } ++ Component ichatmutablecomponent = io.papermc.paper.adventure.PaperAdventure.asVanilla(adventureComponent); // Paper ++ this.connection.send(new ClientboundLoginDisconnectPacket(ichatmutablecomponent)); + this.connection.disconnect(ichatmutablecomponent); + } else { diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 615fb00e50f3c434809f8e1b201d457b9beae8fd..c58fc7d950ea2aa136c3922fb14e4f183f45f2d3 100644 +index 615fb00e50f3c434809f8e1b201d457b9beae8fd..faf1ae03a308ad07091e3e847370e9bda66288b2 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -99,7 +99,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @@ -33,7 +37,7 @@ index 615fb00e50f3c434809f8e1b201d457b9beae8fd..c58fc7d950ea2aa136c3922fb14e4f18 @Deprecated public void disconnect(String s) { - this.disconnect(Component.literal(s)); -+ this.disconnect(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s, true)[0]); // Paper - Fix hex colors not working in some kick messages ++ this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s))); // Paper - Fix hex colors not working in some kick messages } // CraftBukkit end diff --git a/patches/server/0565-Add-bypass-host-check.patch b/patches/server/0565-Add-bypass-host-check.patch index 21a11f4ee..7faab28de 100644 --- a/patches/server/0565-Add-bypass-host-check.patch +++ b/patches/server/0565-Add-bypass-host-check.patch @@ -8,7 +8,7 @@ Paper.bypassHostCheck Seriously, fix your firewalls. -.- diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -index 2ee5c884571228a353120f658f1a2d39373ea4ca..bb8ba0ba5c70f321d4fd195f14cfb4d75ec0e42f 100644 +index 5d7f092e966d5b0496f48bd5c9d274157ac6d250..3068e25f2df958689627fb31783a2d356547f1be 100644 --- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java @@ -30,6 +30,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL @@ -19,7 +19,7 @@ index 2ee5c884571228a353120f658f1a2d39373ea4ca..bb8ba0ba5c70f321d4fd195f14cfb4d7 public ServerHandshakePacketListenerImpl(MinecraftServer server, Connection connection) { this.server = server; -@@ -127,7 +128,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL +@@ -129,7 +130,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL if (!handledByEvent && proxyLogicEnabled) { // Paper end // if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! diff --git a/patches/server/0596-Add-Unix-domain-socket-support.patch b/patches/server/0596-Add-Unix-domain-socket-support.patch index a8a46b776..82fa9eff1 100644 --- a/patches/server/0596-Add-Unix-domain-socket-support.patch +++ b/patches/server/0596-Add-Unix-domain-socket-support.patch @@ -109,7 +109,7 @@ index 598e3ae877f014ce979d8a578445f8a314f0ba82..b7e6c7fdccb91f3cef5e6d96fe5f0c2e } // Spigot End diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -index bb8ba0ba5c70f321d4fd195f14cfb4d75ec0e42f..0b3d6b309ea653d44bcfcd6dd418f692e040c87b 100644 +index 3068e25f2df958689627fb31783a2d356547f1be..d2edc000f34d7f07a840bb8012c6f884f37e387b 100644 --- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java @@ -45,6 +45,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL @@ -128,7 +128,7 @@ index bb8ba0ba5c70f321d4fd195f14cfb4d75ec0e42f..0b3d6b309ea653d44bcfcd6dd418f692 } catch (Throwable t) { org.apache.logging.log4j.LogManager.getLogger().debug("Failed to check connection throttle", t); } -@@ -129,8 +131,11 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL +@@ -131,8 +133,11 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL // Paper end // if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.BYPASS_HOSTCHECK || ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper