PaperMC/patches/server/0404-Fix-hex-colors-not-working-in-some-kick-messages.patch

44 lines
3.7 KiB
Diff
Raw Normal View History

2022-06-08 08:06:17 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: JRoy <joshroy126@gmail.com>
Date: Thu, 27 Aug 2020 16:57:25 -0400
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
2024-06-13 22:57:13 +02:00
index 946b423d2184f903dc29c923d7dbe05aaa469c09..0c1bdf2329936ce479a2cc53e8a46bd2ad685ec1 100644
2022-06-08 08:06:17 +02:00
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
2024-06-13 22:57:13 +02:00
@@ -113,14 +113,16 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
2024-04-24 14:11:27 +02:00
}
// CraftBukkit end
if (packet.protocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
- MutableComponent ichatmutablecomponent;
+ net.kyori.adventure.text.Component adventureComponent; // Paper - Fix hex colors not working in some kick messages
2022-06-08 08:06:17 +02:00
2024-04-24 14:11:27 +02:00
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
+ 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
2024-04-24 14:11:27 +02:00
} else {
- ichatmutablecomponent = Component.literal( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) ); // Spigot
+ 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
2024-04-24 14:11:27 +02:00
}
2022-06-08 08:06:17 +02:00
+ Component ichatmutablecomponent = io.papermc.paper.adventure.PaperAdventure.asVanilla(adventureComponent); // Paper - Fix hex colors not working in some kick messages
+
2024-04-24 14:11:27 +02:00
this.connection.send(new ClientboundLoginDisconnectPacket(ichatmutablecomponent));
2024-06-13 22:57:13 +02:00
this.connection.disconnect((Component) ichatmutablecomponent);
2024-04-24 14:11:27 +02:00
} else {
2022-06-08 08:06:17 +02:00
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
2024-06-13 22:57:13 +02:00
index 53b1fd2d1328bde3fe195964ce39ff5c0f5a7c05..baedae23865ea80c6546d1f6f439e1d7712258b9 100644
2022-06-08 08:06:17 +02:00
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
2024-06-13 22:57:13 +02:00
@@ -128,7 +128,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
2022-06-08 08:06:17 +02:00
// CraftBukkit start
@Deprecated
public void disconnect(String s) {
- this.disconnect(Component.literal(s));
+ 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
2022-06-08 08:06:17 +02:00
}
// CraftBukkit end