Fix NotNull locales (#10216)

Two methods returning locales are annotated @NotNull, despite being able
to return null
This commit is contained in:
Moulberry 2024-02-10 04:30:50 +08:00
parent 4f9f09bb9b
commit 6591c39509
3 changed files with 3 additions and 3 deletions

View File

@ -3608,7 +3608,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public PlayerLocaleChangeEvent(@NotNull Player who, @NotNull String locale) { public PlayerLocaleChangeEvent(@NotNull Player who, @NotNull String locale) {
super(who); super(who);
this.locale = locale; 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
} }
/** /**

View File

@ -2826,7 +2826,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
// CraftBukkit end // CraftBukkit end
this.language = clientOptions.language(); 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.requestedViewDistance = clientOptions.viewDistance();
this.chatVisibility = clientOptions.chatVisibility(); this.chatVisibility = clientOptions.chatVisibility();
this.canChatColor = clientOptions.chatColors(); this.canChatColor = clientOptions.chatColors();

View File

@ -133,7 +133,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public void updateOptionsNoEvents(ClientInformation clientOptions) { + public void updateOptionsNoEvents(ClientInformation clientOptions) {
+ // Paper end + // Paper end
this.language = clientOptions.language(); 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.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 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644