2025-03-26 03:05:00 +11:00
|
|
|
From ef0f887fd2b493a5945e6fd0ac93cc21750b671a Mon Sep 17 00:00:00 2001
|
2014-04-08 14:06:25 +02:00
|
|
|
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
|
2024-12-04 03:20:00 +11:00
|
|
|
index 00000000..2515887c
|
2014-04-08 14:06:25 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/event/player/PlayerSpawnLocationEvent.java
|
2019-03-13 17:43:06 +11:00
|
|
|
@@ -0,0 +1,53 @@
|
2014-04-08 14:06:25 +02:00
|
|
|
+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;
|
2014-04-08 14:06:25 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 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) {
|
2014-04-08 14:06:25 +02:00
|
|
|
+ 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
|
2014-04-08 14:06:25 +02:00
|
|
|
+ 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) {
|
2014-04-08 14:06:25 +02:00
|
|
|
+ this.spawnLocation = location;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-13 17:43:06 +11:00
|
|
|
+ @NotNull
|
2014-04-08 14:06:25 +02:00
|
|
|
+ @Override
|
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-13 17:43:06 +11:00
|
|
|
+ @NotNull
|
2014-04-08 14:06:25 +02:00
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+}
|
2019-12-22 10:00:03 +11:00
|
|
|
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
|
2024-12-04 03:20:00 +11:00
|
|
|
index 00000000..6a2d5d84
|
2019-12-22 10:00:03 +11:00
|
|
|
--- /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;
|
2014-04-08 14:06:25 +02:00
|
|
|
--
|
2025-03-26 03:05:00 +11:00
|
|
|
2.49.0
|
2014-04-08 14:06:25 +02:00
|
|
|
|