aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0041-Add-PlayerLocaleChangeEvent.patch
blob: b4ca003803bde6b2d26ce2da46b629e47960f94c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From 8dff59c6bbe54bad21324805a3302cf346c987c9 Mon Sep 17 00:00:00 2001
From: Isaac Moore <rmsy@me.com>
Date: Fri, 27 Mar 2015 00:52:24 -0400
Subject: [PATCH] Add PlayerLocaleChangeEvent


diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 3810f86..be50b55 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -995,7 +995,13 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
     }
 
     public void a(PacketPlayInSettings packetplayinsettings) {
+        // PaperSpigot start - Add PlayerLocaleChangeEvent
+        String oldLocale = this.locale;
         this.locale = packetplayinsettings.a();
+        if (!this.locale.equals(oldLocale)) {
+            CraftEventFactory.callPlayerLocaleChangeEvent(this, oldLocale, this.locale);
+        }
+        // PaperSpigot end
         this.bR = packetplayinsettings.c();
         this.bS = packetplayinsettings.d();
         this.getDataWatcher().watch(10, Byte.valueOf((byte) packetplayinsettings.e()));
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 147b928..db91503 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -970,4 +970,13 @@ public class CraftEventFactory {
         firework.world.getServer().getPluginManager().callEvent(event);
         return event;
     }
+
+    // PaperSpigot start - Add PlayerLocaleChangeEvent
+    public static PlayerLocaleChangeEvent callPlayerLocaleChangeEvent(EntityHuman who, String oldLocale, String newLocale) {
+        Player player = (Player) who.getBukkitEntity();
+        PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(player, oldLocale, newLocale);
+        Bukkit.getPluginManager().callEvent(event);
+        return event;
+    }
+    // PaperSpigot end
 }
-- 
2.6.0