mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-17 06:27:42 +01:00
fix #1695: add "velocity.legacyChatMaxServerboundLength" system property to allow overriding default legacy chat max length
This commit is contained in:
@@ -32,12 +32,24 @@ public class LegacyChatPacket implements MinecraftPacket {
|
|||||||
public static final byte GAME_INFO_TYPE = (byte) 2;
|
public static final byte GAME_INFO_TYPE = (byte) 2;
|
||||||
|
|
||||||
public static final int MAX_SERVERBOUND_MESSAGE_LENGTH = 256;
|
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);
|
public static final UUID EMPTY_SENDER = new UUID(0, 0);
|
||||||
|
|
||||||
private @Nullable String message;
|
private @Nullable String message;
|
||||||
private byte type;
|
private byte type;
|
||||||
private @Nullable UUID sender;
|
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() {
|
public LegacyChatPacket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +104,10 @@ public class LegacyChatPacket implements MinecraftPacket {
|
|||||||
@Override
|
@Override
|
||||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
|
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
|
||||||
message = ProtocolUtils.readString(buf, direction == ProtocolUtils.Direction.CLIENTBOUND
|
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
|
if (direction == ProtocolUtils.Direction.CLIENTBOUND
|
||||||
&& version.noLessThan(ProtocolVersion.MINECRAFT_1_8)) {
|
&& version.noLessThan(ProtocolVersion.MINECRAFT_1_8)) {
|
||||||
type = buf.readByte();
|
type = buf.readByte();
|
||||||
|
|||||||
Reference in New Issue
Block a user