papermc/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch
Bjarne Koll a24f9b204c
1.21.6 dev
Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
2025-06-17 15:45:25 +02:00

47 lines
2.2 KiB
Diff

--- a/net/minecraft/network/FriendlyByteBuf.java
+++ b/net/minecraft/network/FriendlyByteBuf.java
@@ -71,14 +_,20 @@
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;
private static final int MAX_PUBLIC_KEY_HEADER_SIZE = 256;
private static final int MAX_PUBLIC_KEY_LENGTH = 512;
private static final Gson GSON = new Gson();
+ // Paper start - Track codec depth
+ public boolean trackCodecDepth;
+ public byte codecDepth;
+ // Paper end - Track codec depth
public FriendlyByteBuf(ByteBuf source) {
+ this.adventure$locale = PacketEncoder.ADVENTURE_LOCALE.get(); // Paper - track player's locale for server-side translations
this.source = source;
}
@@ -107,8 +_,13 @@
}
public <T> void writeJsonWithCodec(Codec<T> codec, T value) {
+ // Paper start - Adventure; add max length parameter
+ this.writeJsonWithCodec(codec, value, MAX_STRING_LENGTH);
+ }
+ public <T> void writeJsonWithCodec(Codec<T> codec, T value, int maxLength) {
+ // Paper end - Adventure; add max length parameter
DataResult<JsonElement> 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 <T> IntFunction<T> limitValue(IntFunction<T> function, int limit) {
@@ -556,7 +_,7 @@
try {
NbtIo.writeAnyTag(nbt, new ByteBufOutputStream(buffer));
- } catch (IOException var3) {
+ } catch (Exception var3) { // CraftBukkit - IOException -> Exception
throw new EncoderException(var3);
}
}