From 6591c39509376a817b853d465b6ff1e486905832 Mon Sep 17 00:00:00 2001
From: Moulberry <james.jenour@protonmail.com>
Date: Sat, 10 Feb 2024 04:30:50 +0800
Subject: [PATCH] Fix NotNull locales (#10216)

Two methods returning locales are annotated @NotNull, despite being able
to return null
---
 patches/api/Adventure.patch                              | 2 +-
 patches/server/Adventure.patch                           | 2 +-
 patches/server/Implement-Player-Client-Options-API.patch | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch
index a5346cde98..74a58d0be8 100644
--- a/patches/api/Adventure.patch
+++ b/patches/api/Adventure.patch
@@ -3608,7 +3608,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      public PlayerLocaleChangeEvent(@NotNull Player who, @NotNull String locale) {
          super(who);
          this.locale = locale;
-+        this.adventure$locale = net.kyori.adventure.translation.Translator.parseLocale(locale); // Paper
++        this.adventure$locale = java.util.Objects.requireNonNullElse(net.kyori.adventure.translation.Translator.parseLocale(locale), java.util.Locale.US); // Paper start
      }
  
      /**
diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch
index 968eec4681..95b9577651 100644
--- a/patches/server/Adventure.patch
+++ b/patches/server/Adventure.patch
@@ -2826,7 +2826,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          }
          // CraftBukkit end
          this.language = clientOptions.language();
-+        this.adventure$locale = net.kyori.adventure.translation.Translator.parseLocale(this.language); // Paper
++        this.adventure$locale = java.util.Objects.requireNonNullElse(net.kyori.adventure.translation.Translator.parseLocale(this.language), java.util.Locale.US); // Paper
          this.requestedViewDistance = clientOptions.viewDistance();
          this.chatVisibility = clientOptions.chatVisibility();
          this.canChatColor = clientOptions.chatColors();
diff --git a/patches/server/Implement-Player-Client-Options-API.patch b/patches/server/Implement-Player-Client-Options-API.patch
index 584240c6f3..24889d082b 100644
--- a/patches/server/Implement-Player-Client-Options-API.patch
+++ b/patches/server/Implement-Player-Client-Options-API.patch
@@ -133,7 +133,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    public void updateOptionsNoEvents(ClientInformation clientOptions) {
 +        // Paper end
          this.language = clientOptions.language();
-         this.adventure$locale = net.kyori.adventure.translation.Translator.parseLocale(this.language); // Paper
+         this.adventure$locale = java.util.Objects.requireNonNullElse(net.kyori.adventure.translation.Translator.parseLocale(this.language), java.util.Locale.US); // Paper
          this.requestedViewDistance = clientOptions.viewDistance();
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644