mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-09-06 11:48:05 +02:00
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing BungeeCord Changes: 39a80e41 #3093: Support names with '.', block names with ' ' ab9153dd Further increase length limit for TO_CLIENT chat packets 7ec1f487 Remove ipv6 scope from forwarded addresses
51 lines
2.0 KiB
Diff
51 lines
2.0 KiB
Diff
From 642d3af7c2e2537c49af02090b2ff7f17424c5e9 Mon Sep 17 00:00:00 2001
|
|
From: kashike <kashike@vq.lc>
|
|
Date: Wed, 20 Mar 2019 21:39:12 -0700
|
|
Subject: [PATCH] Use proper max length for serverbound chat packet
|
|
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
|
|
index 0cef9430..d51a3142 100644
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
|
|
@@ -56,6 +56,20 @@ public abstract class DefinedPacket
|
|
return s;
|
|
}
|
|
|
|
+ // Waterfall start
|
|
+ public static void writeString(String s, final int maxLength, ByteBuf buf)
|
|
+ {
|
|
+ if ( s.length() > maxLength )
|
|
+ {
|
|
+ throw new OverflowPacketException( String.format( "Cannot send string longer than %s (got %s characters)", maxLength, s.length() ) );
|
|
+ }
|
|
+
|
|
+ byte[] b = s.getBytes( Charsets.UTF_8 );
|
|
+ writeVarInt( b.length, buf );
|
|
+ buf.writeBytes( b );
|
|
+ }
|
|
+ // Waterfall end
|
|
+
|
|
public static void writeArray(byte[] b, ByteBuf buf)
|
|
{
|
|
if ( b.length > Short.MAX_VALUE )
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java
|
|
index e3a4d250..4749a671 100644
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java
|
|
@@ -54,6 +54,11 @@ public class Chat extends DefinedPacket
|
|
@Override
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // Waterfall start
|
|
+ if (direction == ProtocolConstants.Direction.TO_CLIENT) {
|
|
+ writeString(this.message, Short.MAX_VALUE * 8 + 8, buf);
|
|
+ } else
|
|
+ // Waterfall end
|
|
writeString( message, buf );
|
|
if ( direction == ProtocolConstants.Direction.TO_CLIENT )
|
|
{
|
|
--
|
|
2.31.1.windows.1
|
|
|