spigot/Bukkit-Patches/0011-Add-PlayerSpawnLocationEvent.patch

69 lines
2 KiB
Diff
Raw Normal View History

2019-12-18 08:00:00 +11:00
From fc1f381805b195877f6b00d0583fad4d21262ae9 Mon Sep 17 00:00:00 2001
From: ninja <xninja@openmailbox.org>
Date: Tue, 8 Apr 2014 14:01:32 +0200
Subject: [PATCH] Add PlayerSpawnLocationEvent.
diff --git a/src/main/java/org/spigotmc/event/player/PlayerSpawnLocationEvent.java b/src/main/java/org/spigotmc/event/player/PlayerSpawnLocationEvent.java
new file mode 100644
2019-03-13 17:43:06 +11:00
index 00000000..2515887c
--- /dev/null
+++ b/src/main/java/org/spigotmc/event/player/PlayerSpawnLocationEvent.java
2019-03-13 17:43:06 +11:00
@@ -0,0 +1,53 @@
+package org.spigotmc.event.player;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
2019-03-13 17:43:06 +11:00
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when player is about to spawn in a world after joining the server.
+ */
+public class PlayerSpawnLocationEvent extends PlayerEvent {
+ private static final HandlerList handlers = new HandlerList();
+ private Location spawnLocation;
+
2019-03-13 17:43:06 +11:00
+ public PlayerSpawnLocationEvent(@NotNull final Player who, @NotNull Location spawnLocation) {
+ super(who);
+ this.spawnLocation = spawnLocation;
+ }
+
+
+ /**
+ * Gets player's spawn location.
+ * If the player {@link Player#hasPlayedBefore()}, it's going to default to the location inside player.dat file.
+ * For new players, the default spawn location is spawn of the main Bukkit world.
+ *
+ * @return the spawn location
+ */
2019-03-13 17:43:06 +11:00
+ @NotNull
+ public Location getSpawnLocation() {
+ return spawnLocation;
+ }
+
+ /**
+ * Sets player's spawn location.
+ *
+ * @param location the spawn location
+ */
2019-03-13 17:43:06 +11:00
+ public void setSpawnLocation(@NotNull Location location) {
+ this.spawnLocation = location;
+ }
+
2019-03-13 17:43:06 +11:00
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
2019-03-13 17:43:06 +11:00
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
--
2019-04-23 09:33:25 +10:00
2.20.1