2021-06-11 14:02:28 +02:00
|
|
|
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
|
2021-06-16 01:41:38 +02:00
|
|
|
index 0cb26991acf1d8af3da90a739c722596c4394a9d..71e8b6ecc13eccc9981d06a87a52bd0215e5bbec 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
2021-06-13 07:13:07 +02:00
|
|
|
@@ -1707,7 +1707,7 @@ public class ServerPlayer extends Player {
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2021-06-13 07:13:07 +02:00
|
|
|
@@ -1715,9 +1715,10 @@ public class ServerPlayer extends Player {
|
2021-06-12 06:38:04 +02:00
|
|
|
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT);
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2021-06-12 06:38:04 +02:00
|
|
|
PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(this.getBukkitEntity(), packet.language);
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2021-06-16 01:41:38 +02:00
|
|
|
index 4cbd2fcbbc96d64116665b13f49f0bb3d4b2bca6..3001399cbbe68621a5605436b74e4e96491b5dad 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2021-06-16 01:41:38 +02:00
|
|
|
@@ -1899,8 +1899,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getLocale() {
|
2021-06-12 06:38:04 +02:00
|
|
|
- return this.getHandle().locale;
|
2021-06-11 14:02:28 +02:00
|
|
|
-
|
|
|
|
+ // Paper start - Locale change event
|
2021-06-12 06:38:04 +02:00
|
|
|
+ final String locale = this.getHandle().locale;
|
2021-06-11 14:02:28 +02:00
|
|
|
+ return locale != null ? locale : "en_us";
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paper start
|