Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
Add PlayerLocaleChangeEvent
Dieser Commit ist enthalten in:
Ursprung
0348f3fb5e
Commit
4651b50153
62
Spigot-API-Patches/0010-Add-PlayerLocaleChangeEvent.patch
Normale Datei
62
Spigot-API-Patches/0010-Add-PlayerLocaleChangeEvent.patch
Normale Datei
@ -0,0 +1,62 @@
|
||||
From eb89a2994624f064ca2508434247629e746a8dd4 Mon Sep 17 00:00:00 2001
|
||||
From: Isaac Moore <rmsy@me.com>
|
||||
Date: Mon, 27 Apr 2015 21:41:39 -0500
|
||||
Subject: [PATCH] Add PlayerLocaleChangeEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java b/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java
|
||||
new file mode 100644
|
||||
index 0000000..3efd159
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java
|
||||
@@ -0,0 +1,46 @@
|
||||
+package org.bukkit.event.player;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+
|
||||
+/**
|
||||
+ * Called when the locale of the player is changed.
|
||||
+ */
|
||||
+public class PlayerLocaleChangeEvent extends PlayerEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final String oldLocale;
|
||||
+ private final String newLocale;
|
||||
+
|
||||
+ public PlayerLocaleChangeEvent(final Player player, final String oldLocale, final String newLocale) {
|
||||
+ super(player);
|
||||
+ this.oldLocale = oldLocale;
|
||||
+ this.newLocale = newLocale;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the locale the player switched from.
|
||||
+ *
|
||||
+ * @return player's old locale
|
||||
+ */
|
||||
+ public String getOldLocale() {
|
||||
+ return oldLocale;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the locale the player is changed to.
|
||||
+ *
|
||||
+ * @return player's new locale
|
||||
+ */
|
||||
+ public String getNewLocale() {
|
||||
+ return newLocale;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
--
|
||||
1.9.1
|
||||
|
45
Spigot-Server-Patches/0046-Add-PlayerLocaleChangeEvent.patch
Normale Datei
45
Spigot-Server-Patches/0046-Add-PlayerLocaleChangeEvent.patch
Normale Datei
@ -0,0 +1,45 @@
|
||||
From de519945cdd57668fc80157cdef41431a3e40373 Mon Sep 17 00:00:00 2001
|
||||
From: Isaac Moore <rmsy@me.com>
|
||||
Date: Mon, 27 Apr 2015 21:41:39 -0500
|
||||
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 3854edf..bf83faa 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
@@ -992,7 +992,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 211c421..0950b8a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -950,4 +950,13 @@ public class CraftEventFactory {
|
||||
entityHuman.world.getServer().getPluginManager().callEvent(event);
|
||||
return (Cancellable) 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
|
||||
}
|
||||
--
|
||||
1.9.1
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren