Include RespawnReason

This commit is contained in:
Cryptite 2023-05-03 13:47:08 -05:00
parent 6c4fc6ca3b
commit 2f20697d27
2 changed files with 16 additions and 5 deletions

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Add PlayerPreRespawnLocationEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerPreRespawnLocationEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerPreRespawnLocationEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..7cbe6d1b4d4420e7cccdb0bd54f671569f604c08
index 0000000000000000000000000000000000000000..cf81752c60fb1cd5a649c50acea759036ba9d094
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerPreRespawnLocationEvent.java
@@ -0,0 +1,57 @@
@@ -0,0 +1,68 @@
+package io.papermc.paper.event.player;
+
+import org.apache.commons.lang3.Validate;
@ -26,10 +26,12 @@ index 0000000000000000000000000000000000000000..7cbe6d1b4d4420e7cccdb0bd54f67156
+ */
+public class PlayerPreRespawnLocationEvent extends PlayerEvent {
+ private static final HandlerList handlers = new HandlerList();
+ private final PlayerRespawnEvent.RespawnReason respawnReason;
+ private Location respawnLocation;
+
+ public PlayerPreRespawnLocationEvent(@NotNull final Player respawnPlayer) {
+ public PlayerPreRespawnLocationEvent(@NotNull final Player respawnPlayer, PlayerRespawnEvent.RespawnReason respawnReason) {
+ super(respawnPlayer);
+ this.respawnReason = respawnReason;
+ }
+
+ /**
@ -56,6 +58,15 @@ index 0000000000000000000000000000000000000000..7cbe6d1b4d4420e7cccdb0bd54f67156
+ this.respawnLocation = respawnLocation;
+ }
+
+ /**
+ * Gets the reason this respawn event was called.
+ *
+ * @return the reason the event was called.
+ */
+ public PlayerRespawnEvent.RespawnReason getRespawnReason() {
+ return respawnReason;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerPreRespawnLocationEvent
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 4d837c1530a3031a4c2a5a39d87bd013d60e14a6..c515eb85becbea8e9cad33e1f14f5f0fc3d1f513 100644
index 4d837c1530a3031a4c2a5a39d87bd013d60e14a6..203d43c0902132bed1e396bc956d2313447d3534 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -835,6 +835,14 @@ public abstract class PlayerList {
@ -14,7 +14,7 @@ index 4d837c1530a3031a4c2a5a39d87bd013d60e14a6..c515eb85becbea8e9cad33e1f14f5f0f
if (location == null) {
+ // Paper start
+ Player respawnPlayer = entityplayer1.getBukkitEntity();
+ io.papermc.paper.event.player.PlayerPreRespawnLocationEvent preRespawnEvent = new io.papermc.paper.event.player.PlayerPreRespawnLocationEvent(respawnPlayer);
+ io.papermc.paper.event.player.PlayerPreRespawnLocationEvent preRespawnEvent = new io.papermc.paper.event.player.PlayerPreRespawnLocationEvent(respawnPlayer, reason);
+ preRespawnEvent.callEvent();
+ location = preRespawnEvent.getRespawnLocation();
+