Paper/patches/server/0087-Implement-PlayerLocaleChangeEvent.patch
Nassim Jahnke 06db5d08b0
Updated Upstream (Bukkit/CraftBukkit) (#6589)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
44cfe143 SPIGOT-6249: Add Missing Effect Constants

CraftBukkit Changes:
14928261 SPIGOT-6249: Add Missing Effect Constants
332335e1 SPIGOT-6731: "Nag author" message in CraftServer lists one author only
6cd975d0 SPIGOT-5732, SPIGOT-6387: Overhaul Hanging entities
2021-09-11 19:27:48 +02:00

49 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Isaac Moore <rmsy@me.com>
Date: Tue, 19 Apr 2016 14:09:31 -0500
Subject: [PATCH] Implement PlayerLocaleChangeEvent
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 2b7dd46fe090db01aa4d1f0e4211bed769ad76dc..7e7bbb6817ceddbbb90c1ac45d8e974d3f95c089 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1709,7 +1709,7 @@ public class ServerPlayer extends Player {
return s;
}
- public String locale = "en_us"; // CraftBukkit - add, lowercase
+ public String locale = null; // CraftBukkit - add, lowercase // Paper - default to null
public java.util.Locale adventure$locale = java.util.Locale.US; // Paper
public void updateOptions(ServerboundClientInformationPacket packet) {
// CraftBukkit start
@@ -1717,9 +1717,10 @@ public class ServerPlayer extends Player {
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT);
this.server.server.getPluginManager().callEvent(event);
}
- if (!this.locale.equals(packet.language)) {
+ if (this.locale == null || !this.locale.equals(packet.language)) { // Paper - check for null
PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(this.getBukkitEntity(), packet.language);
this.server.server.getPluginManager().callEvent(event);
+ new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.locale, packet.language).callEvent(); // Paper
}
this.locale = packet.language;
// Paper start
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 9ebeb5c646c8876c52c7e231f315b9c1622f3fad..78e150121a4ebffeed8690dd69b13e386d7485d4 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1906,8 +1906,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public String getLocale() {
- return this.getHandle().locale;
-
+ // Paper start - Locale change event
+ final String locale = this.getHandle().locale;
+ return locale != null ? locale : "en_us";
+ // Paper end
}
// Paper start