From 5320aae5d9a839e3a118d4ada8b1c0d1e901422c Mon Sep 17 00:00:00 2001 From: Riley Park Date: Sun, 25 Jan 2026 21:20:14 -0800 Subject: [PATCH] fix #1695: add "velocity.legacyChatMaxServerboundLength" system property to allow overriding default legacy chat max length --- .../packet/chat/legacy/LegacyChatPacket.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatPacket.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatPacket.java index 80b239d53..f5bb6b4f9 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatPacket.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/chat/legacy/LegacyChatPacket.java @@ -32,12 +32,24 @@ public class LegacyChatPacket implements MinecraftPacket { public static final byte GAME_INFO_TYPE = (byte) 2; public static final int MAX_SERVERBOUND_MESSAGE_LENGTH = 256; + private static final int MAX_SERVERBOUND_MESSAGE_LENGTH_LEGACY = getMaxServerboundMessageLength(); public static final UUID EMPTY_SENDER = new UUID(0, 0); private @Nullable String message; private byte type; private @Nullable UUID sender; + private static int getMaxServerboundMessageLength() { + final String value = System.getProperty("velocity.legacyChatMaxServerboundLength"); + if (value != null) { + try { + return Integer.parseInt(value.trim()); + } catch (final NumberFormatException e) { + } + } + return 100; + } + public LegacyChatPacket() { } @@ -92,7 +104,10 @@ public class LegacyChatPacket implements MinecraftPacket { @Override public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { message = ProtocolUtils.readString(buf, direction == ProtocolUtils.Direction.CLIENTBOUND - ? 262144 : version.noLessThan(ProtocolVersion.MINECRAFT_1_11) ? 256 : 100); + ? 262144 + : version.noLessThan(ProtocolVersion.MINECRAFT_1_11) + ? MAX_SERVERBOUND_MESSAGE_LENGTH + : MAX_SERVERBOUND_MESSAGE_LENGTH_LEGACY); if (direction == ProtocolUtils.Direction.CLIENTBOUND && version.noLessThan(ProtocolVersion.MINECRAFT_1_8)) { type = buf.readByte();