0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/spigot.git synced 2024-11-21 19:46:14 +00:00
spigot/Bukkit-Patches/0008-Add-PlayerSpawnLocationEvent.patch
2024-10-23 02:15:00 +11:00

79 lines
2.3 KiB
Diff

From 0b5f70554c5e1d4ec0ade418edd2ab3907d507f8 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
index 000000000..2515887c2
--- /dev/null
+++ b/src/main/java/org/spigotmc/event/player/PlayerSpawnLocationEvent.java
@@ -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;
+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;
+
+ 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
+ */
+ @NotNull
+ public Location getSpawnLocation() {
+ return spawnLocation;
+ }
+
+ /**
+ * Sets player's spawn location.
+ *
+ * @param location the spawn location
+ */
+ public void setSpawnLocation(@NotNull Location location) {
+ this.spawnLocation = location;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/spigotmc/event/player/package-info.java b/src/main/java/org/spigotmc/event/player/package-info.java
new file mode 100644
index 000000000..6a2d5d84e
--- /dev/null
+++ b/src/main/java/org/spigotmc/event/player/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Spigot-specific player events.
+ */
+package org.spigotmc.event.player;
--
2.47.0