Paper/Spigot-Server-Patches/0142-Implement-PlayerLocaleChangeEvent.patch
Aikar 2cbd400e17 Fix Player View Distance API corrupting Chunk Sending - Fixes #207
The Player View Distance patch has been screwing with the configured world view distance.

The world a player was created in would set the players view distance, which would be locked to that distance.

Then switching worlds would not give you an updated view distance.

This then caused issues with what view distance the player should have in the chunk map and did not send chunks to the client correctly during movement.

This patch has now been changed to use a -1 default for "default" and will not override view distance until someone has actually used the API to change it.
2016-04-23 21:39:22 -04:00

54 Zeilen
2.5 KiB
Diff

From 807032786429cbaf3985e457d83dfdb46a195348 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/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 4bf8344..6fdf276 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -25,7 +25,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class EntityPlayer extends EntityHuman implements ICrafting {
private static final Logger bQ = LogManager.getLogger();
- public String locale = "en_US"; // Spigot private -> public
+ public String locale = null; // Spigot private -> public // Paper - default to null
public PlayerConnection playerConnection;
public final MinecraftServer server;
public final PlayerInteractManager playerInteractManager;
@@ -1076,7 +1076,14 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
public void a(PacketPlayInSettings packetplayinsettings) {
+ // Paper start - add PlayerLocaleChangeEvent
+ // Since the field is initialized to null, this event should always fire the first time the packet is received
+ String oldLocale = this.locale;
this.locale = packetplayinsettings.a();
+ if (!this.locale.equals(oldLocale)) {
+ CraftEventFactory.callEvent(new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), oldLocale, this.locale));
+ }
+ // Paper end
this.cf = packetplayinsettings.c();
this.cg = packetplayinsettings.d();
this.getDataWatcher().set(EntityPlayer.bp, Byte.valueOf((byte) packetplayinsettings.e()));
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 78a8631..003f700 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1654,7 +1654,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public String getLocale()
{
- return getHandle().locale;
+ // Paper start - Locale change event
+ final String locale = getHandle().locale;
+ return locale != null ? locale : "en_US";
+ // Paper end
}
@Override
--
2.8.1