Clean up duplicate PlayerInitialSpawnEvent

Confused on this one, as commit history says Spigots version is older
than our version, so i'm not sure how we ended up duplicating this when
the 2 events are 100% identical.

Subclass spigots event and rely on the inheritance system, and clean up
the duplicate event fires.

Fix Spigots setPosition to use setPositionRaw to avoid chunk load prematurely.
This commit is contained in:
Aikar
2020-04-19 03:11:02 -04:00
parent 9cdf9d5502
commit fd9350e9ba
20 changed files with 74 additions and 98 deletions

View File

@@ -7,7 +7,7 @@ For modifying a player's initial spawn location as they join the server
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java
new file mode 100644
index 000000000..8e407eff1
index 00000000..8b1fdb9d
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java
@@ -0,0 +0,0 @@
@@ -15,47 +15,16 @@ index 000000000..8e407eff1
+
+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;
+import org.spigotmc.event.player.PlayerSpawnLocationEvent;
+
+public class PlayerInitialSpawnEvent extends PlayerEvent {
+ private static final HandlerList handlers = new HandlerList();
+ @NotNull private Location spawnLocation;
+/**
+ * @deprecated Use {@link PlayerSpawnLocationEvent}, Duplicate API
+ */
+public class PlayerInitialSpawnEvent extends PlayerSpawnLocationEvent {
+
+ public PlayerInitialSpawnEvent(@NotNull final Player player, @NotNull final Location spawnLocation) {
+ super(player);
+ this.spawnLocation = spawnLocation;
+ }
+
+ /**
+ * Gets the current spawn location
+ *
+ * @return Location current spawn location
+ */
+ @NotNull
+ public Location getSpawnLocation() {
+ return this.spawnLocation;
+ }
+
+ /**
+ * Sets the new spawn location
+ *
+ * @param spawnLocation new location for the spawn
+ */
+ public void setSpawnLocation(@NotNull Location spawnLocation) {
+ this.spawnLocation = spawnLocation;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ public PlayerInitialSpawnEvent(@NotNull Player who, @NotNull Location spawnLocation) {
+ super(who, spawnLocation);
+ }
+}
--