testserver/patches/server/0038-Implement-PlayerLocale...

49 lines
2.6 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00: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
2022-06-01 06:20:12 +00:00
index 726c5f4ef0ad083d18b23990f1f7b61e3866290c..d184c3f8f8f86b783f17d71886c9b43a74482f2a 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1733,7 +1733,7 @@ public class ServerPlayer extends Player {
2021-06-11 12:02:28 +00: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
@@ -1741,9 +1741,10 @@ public class ServerPlayer extends Player {
2021-06-12 04:38:04 +00:00
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT);
2021-06-11 12:02:28 +00: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 04:38:04 +00:00
PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(this.getBukkitEntity(), packet.language);
2021-06-11 12:02:28 +00:00
this.server.server.getPluginManager().callEvent(event);
2021-11-23 12:15:10 +00:00
+ this.server.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.locale, packet.language)); // Paper
2021-06-11 12:02:28 +00: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
2022-06-01 06:20:12 +00:00
index 6c866e9fc091b8f2b982d5554f381bfed7d669a9..9b03879242d0f299a51cb4e91dd83b68a8ea3b9c 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2022-06-01 06:20:12 +00:00
@@ -1961,8 +1961,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2021-06-11 12:02:28 +00:00
@Override
public String getLocale() {
2021-06-12 04:38:04 +00:00
- return this.getHandle().locale;
2021-06-11 12:02:28 +00:00
-
+ // Paper start - Locale change event
2021-06-12 04:38:04 +00:00
+ final String locale = this.getHandle().locale;
2021-06-11 12:02:28 +00:00
+ return locale != null ? locale : "en_us";
+ // Paper end
}
// Paper start