mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 20:46:59 +01:00
65 lines
5.7 KiB
Diff
65 lines
5.7 KiB
Diff
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
|
|
index 687308a414095f95b567a2993b679d8b62856578..54de844431cf9cc88d6e82014d5eb69babd7784c 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
|
@@ -50,7 +50,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
|
synchronized (ServerHandshakePacketListenerImpl.throttleTracker) {
|
|
if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) {
|
|
ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime);
|
|
- TranslatableComponent chatmessage = new TranslatableComponent(com.destroystokyo.paper.PaperConfig.connectionThrottleKickMessage); // Paper - Configurable connection throttle kick message
|
|
+ Component 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.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
|
|
this.connection.disconnect(chatmessage);
|
|
return;
|
|
@@ -76,12 +76,12 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
|
}
|
|
// CraftBukkit end
|
|
if (packet.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
|
|
- TranslatableComponent chatmessage;
|
|
+ Component chatmessage; // Paper - Fix hex colors not working in some kick messages
|
|
|
|
if (packet.getProtocolVersion() < 754) {
|
|
- chatmessage = new TranslatableComponent( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) ); // Spigot
|
|
+ chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
|
|
} else {
|
|
- chatmessage = new TranslatableComponent( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) ); // Spigot
|
|
+ chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
|
|
}
|
|
|
|
this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
|
|
@@ -99,7 +99,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
|
if (event.callEvent()) {
|
|
// If we've failed somehow, let the client know so and go no further.
|
|
if (event.isFailed()) {
|
|
- TranslatableComponent chatmessage = new TranslatableComponent(event.getFailMessage());
|
|
+ Component chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(event.getFailMessage(), true)[0]; // Paper - Fix hex colors not working in some kick messages
|
|
this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
|
|
this.connection.disconnect(chatmessage);
|
|
return;
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
index d21f45d983bf3047811d2d73f4a38deb108ac402..ab21f25a3eb0575d08aeac717ba2b74160f54fa9 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
@@ -102,14 +102,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
|
|
// CraftBukkit start
|
|
@Deprecated
|
|
public void disconnect(String s) {
|
|
- try {
|
|
- Component ichatbasecomponent = new TextComponent(s);
|
|
- ServerLoginPacketListenerImpl.LOGGER.info("Disconnecting {}: {}", this.getUserName(), s);
|
|
- this.connection.send(new ClientboundLoginDisconnectPacket(ichatbasecomponent));
|
|
- this.connection.disconnect(ichatbasecomponent);
|
|
- } catch (Exception exception) {
|
|
- ServerLoginPacketListenerImpl.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
|
|
|