Paper/patches/server/0038-Implement-PlayerLocaleChangeEvent.patch
Nassim Jahnke 1cfd363d32
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
fc460d1b PR-735: Add Villager#zombify
c8c8331e PR-690: Add method to read ItemStack input
62845f2f SPIGOT-6829: Add per-player world border API

CraftBukkit Changes:
a459f4d4 PR-1033: Add Villager#zombify
d65d1430 PR-975: Add method to read ItemStack input
b5559f8c SPIGOT-6990: Fix setRepairCost(0) in Anvil
6c308e1b SPIGOT-6829: Add per-player world border API

Spigot Changes:
42b61526 SPIGOT-7000: Generation and /locate issues when using custom structure seeds
2022-04-16 10:29:50 +02:00

49 lines
2.6 KiB
Diff

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
index 58943b2c2cb416753c60ca5cd4445911ab98eeb6..1705a2bb3497546635a1b82dcd8d23cb87c21084 100644
--- 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 {
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 {
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT);
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
PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(this.getBukkitEntity(), packet.language);
this.server.server.getPluginManager().callEvent(event);
+ this.server.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.locale, packet.language)); // 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
index 06cdb4b572a456c1daabdd34d4ca1a2670bfd5fe..68e61e9509565474a800cce4e36112ea3a322591 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1953,8 +1953,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public String getLocale() {
- return this.getHandle().locale;
-
+ // Paper start - Locale change event
+ final String locale = this.getHandle().locale;
+ return locale != null ? locale : "en_us";
+ // Paper end
}
// Paper start