papermc/Bukkit-Patches/0026-Add-PlayerSpawnLocationEvent.patch
Zach Brown 19972e09b8 Update SpigotMC's patches
5a0150f586ed3eb15fe6f1f596d1a5a7d806f0f9 Fix ITEM_BREAK
e6a3911057bd94d8bd7021cbb4923fb84fb106d1 Upstream merge
d1cdcf8d4c3639f956474f02ed662517cffbe23e Remove old patch
068df64aeee368377e1673667bffc7a6dcf90554 Rebuild all patches
2014-11-30 16:16:48 -06:00

65 lines
1.9 KiB
Diff

From c3183b435807fa97baad65b698066e9a15a2ae47 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 0000000..dd3f58c
--- /dev/null
+++ b/src/main/java/org/spigotmc/event/player/PlayerSpawnLocationEvent.java
@@ -0,0 +1,50 @@
+package org.spigotmc.event.player;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+
+/**
+ * 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(final Player who, 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
+ */
+ public Location getSpawnLocation() {
+ return spawnLocation;
+ }
+
+ /**
+ * Sets player's spawn location.
+ *
+ * @param location the spawn location
+ */
+ public void setSpawnLocation(Location location) {
+ this.spawnLocation = location;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
--
2.1.0