2023-09-21 21:54:46 +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
|
2024-04-12 21:14:06 +02:00
|
|
|
index 68a376743e531dfe06bf6bd7b5be3e7d8e3154d8..e3e96008d69926c831e5f42b28e1e70160a3c5bd 100644
|
2023-09-21 21:54:46 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
2023-12-05 20:39:26 +01:00
|
|
|
@@ -222,7 +222,7 @@ public class ServerPlayer extends Player {
|
2023-09-21 21:54:46 +02:00
|
|
|
private int levitationStartTime;
|
|
|
|
private boolean disconnected;
|
|
|
|
private int requestedViewDistance;
|
|
|
|
- public String language = "en_us"; // CraftBukkit - default
|
|
|
|
+ public String language = null; // CraftBukkit - default // Paper - default to null
|
|
|
|
public java.util.Locale adventure$locale = java.util.Locale.US; // Paper
|
|
|
|
@Nullable
|
|
|
|
private Vec3 startingToFallPosition;
|
2024-01-24 13:07:40 +01:00
|
|
|
@@ -272,7 +272,7 @@ public class ServerPlayer extends Player {
|
2023-09-21 21:54:46 +02:00
|
|
|
this.lastActionTime = Util.getMillis();
|
|
|
|
this.recipeBook = new ServerRecipeBook();
|
|
|
|
this.requestedViewDistance = 2;
|
|
|
|
- this.language = "en_us";
|
|
|
|
+ this.language = null; // Paper - default to null
|
|
|
|
this.lastSectionPos = SectionPos.of(0, 0, 0);
|
|
|
|
this.chunkTrackingView = ChunkTrackingView.EMPTY;
|
|
|
|
this.respawnDimension = Level.OVERWORLD;
|
2024-01-24 13:07:40 +01:00
|
|
|
@@ -1920,9 +1920,10 @@ public class ServerPlayer extends Player {
|
2023-10-27 01:34:58 +02:00
|
|
|
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), this.getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT);
|
2023-09-21 21:54:46 +02:00
|
|
|
this.server.server.getPluginManager().callEvent(event);
|
|
|
|
}
|
|
|
|
- if (!this.language.equals(clientOptions.language())) {
|
|
|
|
+ if (this.language == null || !this.language.equals(clientOptions.language())) { // Paper
|
|
|
|
PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(this.getBukkitEntity(), clientOptions.language());
|
|
|
|
this.server.server.getPluginManager().callEvent(event);
|
|
|
|
+ this.server.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.language, clientOptions.language())); // Paper
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
this.language = clientOptions.language();
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2024-04-20 15:24:42 +02:00
|
|
|
index 4655d1c493651779c2038776e4d6fef23c7e7b43..245f58942b6a69a67fa7ed31121d461e27a98ae0 100644
|
2023-09-21 21:54:46 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2024-04-20 15:24:42 +02:00
|
|
|
@@ -2338,7 +2338,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2023-09-21 21:54:46 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getLocale() {
|
|
|
|
- return this.getHandle().language;
|
|
|
|
+ // Paper start - Locale change event
|
|
|
|
+ final String locale = this.getHandle().language;
|
|
|
|
+ return locale != null ? locale : "en_us";
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paper start
|