From f8f2bd7db7d506bcab32be0bdc7ee3ad92c47f4e Mon Sep 17 00:00:00 2001 From: metabrix <admin@epserv.ru> Date: Tue, 6 Aug 2024 00:02:19 +0500 Subject: [PATCH] Fix wrong assumption about locale being null in the login phase (#11204) Fixes #11203 --- patches/server/Adventure.patch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 239ffe15ad..40c5340aba 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -2599,8 +2599,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - buf.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY)); + // Paper start - Adventure + // buf.writeUtf(Component.Serializer.toJson(this.reason, RegistryAccess.EMPTY)); -+ // In the login phase, buf.adventure$locale field is always null -+ buf.writeJsonWithCodec(net.minecraft.network.chat.ComponentSerialization.localizedCodec(java.util.Locale.US), this.reason, FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH); ++ // In the login phase, buf.adventure$locale field is most likely null, but plugins may use internals to set it via the channel attribute ++ java.util.Locale bufLocale = buf.adventure$locale; ++ buf.writeJsonWithCodec(net.minecraft.network.chat.ComponentSerialization.localizedCodec(bufLocale == null ? java.util.Locale.US : bufLocale), this.reason, FriendlyByteBuf.MAX_COMPONENT_STRING_LENGTH); + // Paper end - Adventure }