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/EntityPlayer.java b/src/main/java/net/minecraft/server/level/EntityPlayer.java index ad55212370e3d814a397680927a1514ea0fe85b5..120cad4e7330900fa11d278cf87a6ab4484469c3 100644 --- a/src/main/java/net/minecraft/server/level/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/level/EntityPlayer.java @@ -1686,7 +1686,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { 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 a(PacketPlayInSettings packetplayinsettings) { // CraftBukkit start @@ -1694,9 +1694,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting { PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT); this.server.server.getPluginManager().callEvent(event); } - if (!this.locale.equals(packetplayinsettings.locale)) { + if (this.locale == null || !this.locale.equals(packetplayinsettings.locale)) { // Paper - check for null PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.locale); this.server.server.getPluginManager().callEvent(event); + new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.locale, packetplayinsettings.locale).callEvent(); // Paper } this.locale = packetplayinsettings.locale; // 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 46af184cd8280822170f28464eb32595733234c3..26396ca131d81b7357c31b3475eea8b2a7fb8638 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1879,8 +1879,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public String getLocale() { - return getHandle().locale; - + // Paper start - Locale change event + final String locale = getHandle().locale; + return locale != null ? locale : "en_us"; + // Paper end } // Paper start