--- a/net/minecraft/network/FriendlyByteBuf.java +++ b/net/minecraft/network/FriendlyByteBuf.java @@ -70,6 +_,7 @@ public class FriendlyByteBuf extends ByteBuf { public static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; + @Nullable public final java.util.Locale adventure$locale; // Paper - track player's locale for server-side translations public static final short MAX_STRING_LENGTH = 32767; public static final int MAX_COMPONENT_STRING_LENGTH = 262144; private static final int PUBLIC_KEY_SIZE = 256; @@ -78,6 +_,7 @@ private static final Gson GSON = new Gson(); public FriendlyByteBuf(ByteBuf source) { + this.adventure$locale = PacketEncoder.ADVENTURE_LOCALE.get(); // Paper - track player's locale for server-side translations this.source = source; } @@ -106,8 +_,13 @@ } public void writeJsonWithCodec(Codec codec, T value) { + // Paper start - Adventure; add max length parameter + this.writeJsonWithCodec(codec, value, MAX_STRING_LENGTH); + } + public void writeJsonWithCodec(Codec codec, T value, int maxLength) { + // Paper end - Adventure; add max length parameter DataResult dataResult = codec.encodeStart(JsonOps.INSTANCE, value); - this.writeUtf(GSON.toJson(dataResult.getOrThrow(exception -> new EncoderException("Failed to encode: " + exception + " " + value)))); + this.writeUtf(GSON.toJson(dataResult.getOrThrow(exception -> new EncoderException("Failed to encode: " + exception + " " + value))), maxLength); // Paper - Adventure; add max length parameter } public static IntFunction limitValue(IntFunction function, int limit) { @@ -527,7 +_,7 @@ try { NbtIo.writeAnyTag(nbt, new ByteBufOutputStream(buffer)); - } catch (IOException var3) { + } catch (Exception var3) { // CraftBukkit - IOException -> Exception throw new EncoderException(var3); } }