From 2f20697d2704cf265e2ffeb880a9befb8fa9d48a Mon Sep 17 00:00:00 2001 From: Cryptite Date: Wed, 3 May 2023 13:47:08 -0500 Subject: [PATCH] Include RespawnReason --- ...0417-Add-PlayerPreRespawnLocationEvent.patch | 17 ++++++++++++++--- ...0977-Add-PlayerPreRespawnLocationEvent.patch | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/patches/api/0417-Add-PlayerPreRespawnLocationEvent.patch b/patches/api/0417-Add-PlayerPreRespawnLocationEvent.patch index f0a5d27e42..8e3e432522 100644 --- a/patches/api/0417-Add-PlayerPreRespawnLocationEvent.patch +++ b/patches/api/0417-Add-PlayerPreRespawnLocationEvent.patch @@ -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() { diff --git a/patches/server/0977-Add-PlayerPreRespawnLocationEvent.patch b/patches/server/0977-Add-PlayerPreRespawnLocationEvent.patch index ac5deac925..1be651f282 100644 --- a/patches/server/0977-Add-PlayerPreRespawnLocationEvent.patch +++ b/patches/server/0977-Add-PlayerPreRespawnLocationEvent.patch @@ -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(); +