diff options
Diffstat (limited to 'patches/server/0044-Implement-PlayerLocaleChangeEvent.patch')
-rw-r--r-- | patches/server/0044-Implement-PlayerLocaleChangeEvent.patch | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/patches/server/0044-Implement-PlayerLocaleChangeEvent.patch b/patches/server/0044-Implement-PlayerLocaleChangeEvent.patch new file mode 100644 index 0000000000..fa3a977c10 --- /dev/null +++ b/patches/server/0044-Implement-PlayerLocaleChangeEvent.patch @@ -0,0 +1,56 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Isaac Moore <[email protected]> +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 3bb3312da2b91616d9d3bb4cb79259ee9e3479bd..f21174c1d50158330b9a48dba8409919a2229927 100644 +--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java ++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +@@ -222,7 +222,7 @@ public class ServerPlayer extends Player { + private int levitationStartTime; + private boolean disconnected; + private int requestedViewDistance; +- public String language = "en_us"; // CraftBukkit - default ++ public String language = null; // CraftBukkit - default // Paper - default to null + public java.util.Locale adventure$locale = java.util.Locale.US; // Paper + @Nullable + private Vec3 startingToFallPosition; +@@ -272,7 +272,7 @@ public class ServerPlayer extends Player { + this.lastActionTime = Util.getMillis(); + this.recipeBook = new ServerRecipeBook(); + this.requestedViewDistance = 2; +- this.language = "en_us"; ++ this.language = null; // Paper - default to null + this.lastSectionPos = SectionPos.of(0, 0, 0); + this.chunkTrackingView = ChunkTrackingView.EMPTY; + this.respawnDimension = Level.OVERWORLD; +@@ -1920,9 +1920,10 @@ public class ServerPlayer extends Player { + PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), this.getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT); + this.server.server.getPluginManager().callEvent(event); + } +- if (!this.language.equals(clientOptions.language())) { ++ if (this.language == null || !this.language.equals(clientOptions.language())) { // Paper + PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(this.getBukkitEntity(), clientOptions.language()); + this.server.server.getPluginManager().callEvent(event); ++ this.server.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.language, clientOptions.language())); // Paper + } + // CraftBukkit end + this.language = clientOptions.language(); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index 6e47cd5cc17ad7edff3d946364485bb01bf87a41..42b27e1b8bc317a4cd0fcc27a5d7ce2d69d33aeb 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -2336,7 +2336,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + + @Override + public String getLocale() { +- return this.getHandle().language; ++ // Paper start - Locale change event ++ final String locale = this.getHandle().language; ++ return locale != null ? locale : "en_us"; ++ // Paper end + } + + // Paper start |