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
|
2023-06-13 01:51:45 +02:00
|
|
|
index 1ef48b8415242942f00c6a76faa1de2865e11358..bcf0d4cfbfbae254bc74ad6389af372a8aa319be 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
|
2023-06-08 07:21:04 +02:00
|
|
|
@@ -1853,7 +1853,7 @@ public class ServerPlayer extends Player {
|
2023-03-14 19:36:39 +01:00
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- 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
|
2023-06-08 07:21:04 +02:00
|
|
|
@@ -1861,9 +1861,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);
|
2021-11-23 13:15:10 +01:00
|
|
|
+ this.server.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.locale, packet.language)); // Paper
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
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
|
2023-07-04 10:22:56 +02:00
|
|
|
index 908cff4daf9c4218c8f93fdb7df9e9fa65b06d6f..705734e2f26f8deab8ac9ad929d7b5e29181ace3 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
|
2023-07-04 10:22:56 +02:00
|
|
|
@@ -2202,8 +2202,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
|