PaperMC/patches/api/0017-Add-PlayerLocaleChangeEvent.patch

73 lines
2.2 KiB
Diff
Raw Permalink Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Isaac Moore <rmsy@me.com>
Date: Mon, 29 Feb 2016 18:02:25 -0600
Subject: [PATCH] Add PlayerLocaleChangeEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java
new file mode 100644
2024-02-01 10:15:57 +01:00
index 0000000000000000000000000000000000000000..57f6c47e4e759abf0af9aa8962551225cc12246c
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,60 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.event.player;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.ApiStatus;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
+
+/**
+ * Called when the locale of the player is changed.
+ *
+ * @deprecated Replaced by {@link org.bukkit.event.player.PlayerLocaleChangeEvent} upstream
+ */
+@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
2021-06-11 14:02:28 +02:00
+public class PlayerLocaleChangeEvent extends PlayerEvent {
2024-02-01 10:15:57 +01:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
2021-06-11 14:02:28 +02:00
+ private final String oldLocale;
+ private final String newLocale;
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
+ public PlayerLocaleChangeEvent(final @NotNull Player player, final @Nullable String oldLocale, final @NotNull String newLocale) {
2021-06-11 14:02:28 +02:00
+ super(player);
+ this.oldLocale = oldLocale;
+ this.newLocale = newLocale;
+ }
+
+ /**
+ * Gets the locale the player switched from.
+ *
+ * @return player's old locale
+ */
2024-02-01 10:15:57 +01:00
+ @Nullable
2021-06-11 14:02:28 +02:00
+ public String getOldLocale() {
2024-02-01 10:15:57 +01:00
+ return this.oldLocale;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Gets the locale the player is changed to.
+ *
+ * @return player's new locale
+ */
2024-02-01 10:15:57 +01:00
+ @NotNull
2021-06-11 14:02:28 +02:00
+ public String getNewLocale() {
2024-02-01 10:15:57 +01:00
+ return this.newLocale;
2021-06-11 14:02:28 +02:00
+ }
+
+ @Override
2024-02-01 10:15:57 +01:00
+ @NotNull
2021-06-11 14:02:28 +02:00
+ public HandlerList getHandlers() {
2024-02-01 10:15:57 +01:00
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01:00
+ @NotNull
2021-06-11 14:02:28 +02:00
+ public static HandlerList getHandlerList() {
2024-02-01 10:15:57 +01:00
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+}