From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Isaac Moore 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 68bc585a446585bfc3922db8e4539a25f846e308..2903f3d98949b5a582bf7996b73083f1941a664d 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -1707,7 +1707,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 @@ -1715,9 +1715,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 a027b08d34993d920ded7e94e278314431c182ce..e9fd0737fb122e2beb12898a2d082aebd11604ed 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1900,8 +1900,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