2023-05-01 22:25:26 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Cryptite <cryptite@gmail.com>
|
|
|
|
Date: Mon, 1 May 2023 15:23:34 -0500
|
2023-05-03 18:14:09 +02:00
|
|
|
Subject: [PATCH] Add PlayerPreRespawnLocationEvent
|
2023-05-01 22:25:26 +02:00
|
|
|
|
|
|
|
|
2023-05-03 18:14:09 +02:00
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerPreRespawnLocationEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerPreRespawnLocationEvent.java
|
2023-05-01 22:25:26 +02:00
|
|
|
new file mode 100644
|
2023-05-03 18:14:09 +02:00
|
|
|
index 0000000000000000000000000000000000000000..b321cc19d6ca57050233339ced6c84d9f793f1b6
|
2023-05-01 22:25:26 +02:00
|
|
|
--- /dev/null
|
2023-05-03 18:14:09 +02:00
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerPreRespawnLocationEvent.java
|
|
|
|
@@ -0,0 +1,57 @@
|
2023-05-01 23:33:31 +02:00
|
|
|
+package com.destroystokyo.paper.event.player;
|
2023-05-01 22:25:26 +02:00
|
|
|
+
|
|
|
|
+import org.apache.commons.lang3.Validate;
|
|
|
|
+import org.bukkit.Location;
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.event.HandlerList;
|
2023-05-01 23:33:31 +02:00
|
|
|
+import org.bukkit.event.player.PlayerEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerRespawnEvent;
|
2023-05-01 22:25:26 +02:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
+import org.jetbrains.annotations.Nullable;
|
|
|
|
+
|
|
|
|
+/**
|
2023-05-01 23:33:31 +02:00
|
|
|
+ * Called when a respawn event tries to determine the location of a respawn. This is called before {@link PlayerRespawnEvent}
|
2023-05-01 22:25:26 +02:00
|
|
|
+ */
|
2023-05-03 18:14:09 +02:00
|
|
|
+public class PlayerPreRespawnLocationEvent extends PlayerEvent {
|
2023-05-01 22:25:26 +02:00
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
|
|
+ private Location respawnLocation;
|
|
|
|
+
|
2023-05-03 18:14:09 +02:00
|
|
|
+ public PlayerPreRespawnLocationEvent(@NotNull final Player respawnPlayer) {
|
2023-05-01 22:25:26 +02:00
|
|
|
+ super(respawnPlayer);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the current respawn location
|
|
|
|
+ *
|
|
|
|
+ * @return Location current respawn location
|
|
|
|
+ */
|
|
|
|
+ @Nullable
|
|
|
|
+ public Location getRespawnLocation() {
|
|
|
|
+ return this.respawnLocation;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2023-05-03 18:14:09 +02:00
|
|
|
+ * Sets the new respawn location.
|
2023-05-01 22:25:26 +02:00
|
|
|
+ *
|
2023-05-03 18:14:09 +02:00
|
|
|
+ * @param respawnLocation The exact location for the respawn.<br/>
|
|
|
|
+ * <b>Note:</b> If this is provided, <b>no vanilla logic that calculates "safe" respawn locations will be done.</b> It is up to you to ensure you are
|
|
|
|
+ * providing a good respawn location for a Player.
|
2023-05-01 22:25:26 +02:00
|
|
|
+ */
|
|
|
|
+ public void setRespawnLocation(@NotNull Location respawnLocation) {
|
|
|
|
+ Validate.notNull(respawnLocation, "Respawn location can not be null");
|
|
|
|
+ Validate.notNull(respawnLocation.getWorld(), "Respawn world can not be null");
|
|
|
|
+
|
|
|
|
+ this.respawnLocation = respawnLocation;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @NotNull
|
|
|
|
+ @Override
|
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @NotNull
|
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+}
|