mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-06 11:58:10 +02:00
65 lines
5.5 KiB
Diff
65 lines
5.5 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 6f98be2b9b00f71dd041e7511c70166fdecf0749..c648b73a4c478f9d8020274205d6684f7c7c416f 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 (throttleTracker) {
|
||
|
if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
|
||
|
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()) {
|
||
|
- 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.getNetworkManager().send(new ClientboundLoginDisconnectPacket(chatmessage));
|
||
|
this.getNetworkManager().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 659bf14cf3c949b896d0333f893a3d5e16ab9c92..573963a09f15046cfcaab83aef906801ce70d75a 100644
|
||
|
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||
|
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||
|
@@ -104,14 +104,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
|
||
|
|