Fix some modded clients getting kicked for invalid payload - Fixes #4201

This commit is contained in:
Aikar 2020-08-25 20:03:24 -04:00
parent 7f0786cdd1
commit 167b1db604
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Brand support
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index bc613281d18efac7bb926d84ec54653368b93f43..250ae81b8ce99a2470c1fadc74e167586976a704 100644
index bc613281d18efac7bb926d84ec54653368b93f43..1519813d35541199e860234dc3fb121a35604c0f 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -4,6 +4,7 @@ import com.google.common.primitives.Doubles;
@ -34,19 +34,20 @@ index bc613281d18efac7bb926d84ec54653368b93f43..250ae81b8ce99a2470c1fadc74e16758
@Override
public void a(PacketPlayInCustomPayload packetplayincustompayload) {
PlayerConnectionUtils.ensureMainThread(packetplayincustompayload, this, this.player.getWorldServer());
@@ -2759,6 +2764,11 @@ public class PlayerConnection implements PacketListenerPlayIn {
@@ -2759,6 +2764,12 @@ public class PlayerConnection implements PacketListenerPlayIn {
try {
byte[] data = new byte[packetplayincustompayload.data.readableBytes()];
packetplayincustompayload.data.readBytes(data);
+
+ // Paper start - Brand support
+ if (packetplayincustompayload.tag.equals(MINECRAFT_BRAND))
+ this.clientBrandName = new PacketDataSerializer(Unpooled.copiedBuffer(data)).readUTF(256);
+ if (packetplayincustompayload.tag.equals(MINECRAFT_BRAND)) {
+ this.clientBrandName = data.length < 512 ? new String(data) : "unknown-too-large";
+ }
+ // Paper end
server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.tag.toString(), data);
} catch (Exception ex) {
PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex);
@@ -2768,6 +2778,12 @@ public class PlayerConnection implements PacketListenerPlayIn {
@@ -2768,6 +2779,12 @@ public class PlayerConnection implements PacketListenerPlayIn {
}