2020-11-03 03:22:15 +01: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
2021-03-16 08:19:45 +01:00
diff --git a/src/main/java/net/minecraft/server/network/HandshakeListener.java b/src/main/java/net/minecraft/server/network/HandshakeListener.java
index 6d001843d8f899e91f19c384ddf57e6987bfb79e..b97d289afdff81d9959e238639f4e3e186f8e9c8 100644
--- a/src/main/java/net/minecraft/server/network/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/network/HandshakeListener.java
@@ -46,7 +46,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
2020-11-03 03:22:15 +01:00
synchronized (throttleTracker) {
if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
throttleTracker.put(address, currentTime);
- ChatMessage chatmessage = new ChatMessage(com.destroystokyo.paper.PaperConfig.connectionThrottleKickMessage); // Paper - Configurable connection throttle kick message
+ IChatBaseComponent chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(com.destroystokyo.paper.PaperConfig.connectionThrottleKickMessage, true)[0]; // Paper - Configurable connection throttle kick message // Paper - Fix hex colors not working in some kick messages
this.c.sendPacket(new PacketLoginOutDisconnect(chatmessage));
this.c.close(chatmessage);
return;
2021-03-16 08:19:45 +01:00
@@ -72,12 +72,12 @@ public class HandshakeListener implements PacketHandshakingInListener {
2020-11-03 03:22:15 +01:00
}
// CraftBukkit end
if (packethandshakinginsetprotocol.c() != SharedConstants.getGameVersion().getProtocolVersion()) {
- ChatMessage chatmessage;
+ IChatBaseComponent chatmessage; // Paper - Fix hex colors not working in some kick messages
if (packethandshakinginsetprotocol.c() < 754) {
- chatmessage = new ChatMessage( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getGameVersion().getName() ) ); // Spigot
+ chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getGameVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
} else {
- chatmessage = new ChatMessage( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getGameVersion().getName() ) ); // Spigot
+ chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getGameVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
}
this.c.sendPacket(new PacketLoginOutDisconnect(chatmessage));
2021-03-16 08:19:45 +01:00
@@ -94,7 +94,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
2020-11-03 03:22:15 +01:00
if (event.callEvent()) {
// If we've failed somehow, let the client know so and go no further.
if (event.isFailed()) {
- chatmessage = new ChatMessage(event.getFailMessage());
+ IChatBaseComponent chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(event.getFailMessage(), true)[0]; // Paper - Fix hex colors not working in some kick messages
this.getNetworkManager().sendPacket(new PacketLoginOutDisconnect(chatmessage));
this.getNetworkManager().close(chatmessage);
return;
2021-03-16 08:19:45 +01:00
diff --git a/src/main/java/net/minecraft/server/network/LoginListener.java b/src/main/java/net/minecraft/server/network/LoginListener.java
2021-03-16 14:04:28 +01:00
index 39aa50a386d0ab94914cd8f85c69cf404e0dc4b2..185667110cd6f566b23546728d20fc79223f3c92 100644
2021-03-16 08:19:45 +01:00
--- a/src/main/java/net/minecraft/server/network/LoginListener.java
+++ b/src/main/java/net/minecraft/server/network/LoginListener.java
2021-03-16 14:04:28 +01:00
@@ -106,14 +106,7 @@ public class LoginListener implements PacketLoginInListener {
2020-11-03 03:22:15 +01:00
// CraftBukkit start
@Deprecated
public void disconnect(String s) {
- try {
- IChatBaseComponent ichatbasecomponent = new ChatComponentText(s);
- LoginListener.LOGGER.info("Disconnecting {}: {}", this.d(), s);
- this.networkManager.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent));
- this.networkManager.close(ichatbasecomponent);
- } catch (Exception exception) {
- LoginListener.LOGGER.error("Error whilst disconnecting player", exception);
- }
+ disconnect(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s, true)[0]); // Paper - Fix hex colors not working in some kick messages
}
// CraftBukkit end