Fix reading the brand message from clients

Also try to catch the exception caused by clients/plugins seemingly
mangling this information
This commit is contained in:
Shane Freeder 2020-08-27 17:11:13 +01:00
parent 5591eeb4c2
commit c02f7541d2

View File

@ -41,7 +41,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ // Paper start - Brand support
+ if (packetplayincustompayload.tag.equals(MINECRAFT_BRAND)) {
+ this.clientBrandName = data.length < 512 ? new String(data) : "unknown-too-large";
+ try {
+ this.clientBrandName = new PacketDataSerializer(Unpooled.copiedBuffer(data)).readUTF(256);
+ } catch (StringIndexOutOfBoundsException ex) {
+ this.clientBrandName = "illegal";
+ }
+ }
+ // Paper end
server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.tag.toString(), data);