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-11-05 15:08:24 +01:00
|
|
|
index 3f3404d7d890864fcdcde7d65f726d288ddec688..da722cddaaa8c40715748de81104a5b213c2fea8 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-08-13 19:08:34 +02:00
|
|
|
@@ -1709,7 +1709,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-08-13 19:08:34 +02:00
|
|
|
@@ -1717,9 +1717,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-11-05 15:08:24 +01:00
|
|
|
index 4592ac12058e7cf575ceb47a0021528f5dd91b0a..8fc027fbbc3f5fc3ecdd8fce4f3b2eb510fa76da 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-11-05 15:08:24 +01:00
|
|
|
@@ -1913,8 +1913,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
|