aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0043-Implement-PlayerLocaleChangeEvent.patch
blob: 8fc7a9d370f55d470030ff8792b9bfa50eff31db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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 301f78d1f9a0eae05096de071bda7def3a45f648..54f585f12890c665a097845acfe13108691f12b6 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1755,7 +1755,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
@@ -1763,9 +1763,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);
+            this.server.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.locale, packet.language)); // 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 8e6e7c5960b9273e816d7275b8a3058024190f5a..3be63b51511fd12f295e1f07549f281246ee2dc0 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2084,8 +2084,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