50 lines
3.4 KiB
Diff
50 lines
3.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cryptite <cryptite@gmail.com>
|
|
Date: Sat, 28 Dec 2024 07:59:54 -0600
|
|
Subject: [PATCH] Add PlayerPreRespawnEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index 46f060f33fcbc6a4568a7fcfba29e83a4d192578..28b1ec198970b88515b37ef651c90916f3aef347 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -808,19 +808,31 @@ public abstract class PlayerList {
|
|
// Paper end - Add PlayerPostRespawnEvent
|
|
|
|
// CraftBukkit start - fire PlayerRespawnEvent
|
|
- TeleportTransition teleporttransition;
|
|
+ TeleportTransition teleporttransition = null;
|
|
if (location == null) {
|
|
- teleporttransition = entityplayer.findRespawnPositionAndUseSpawnBlock(!flag, TeleportTransition.DO_NOTHING, reason);
|
|
+ // Slice start
|
|
+ io.papermc.paper.event.player.PlayerPreRespawnEvent preRespawnEvent = new io.papermc.paper.event.player.PlayerPreRespawnEvent(entityplayer.getBukkitEntity(), reason);
|
|
+ if (!preRespawnEvent.callEvent()) return entityplayer;
|
|
+
|
|
+ Location respawnLocation = preRespawnEvent.getRespawnLocation();
|
|
+ if (respawnLocation != null) {
|
|
+ location = respawnLocation;
|
|
+ teleporttransition = new TeleportTransition(((CraftWorld) respawnLocation.getWorld()).getHandle(), CraftLocation.toVec3D(respawnLocation), Vec3.ZERO, respawnLocation.getYaw(), respawnLocation.getPitch(), TeleportTransition.DO_NOTHING);
|
|
+ } else {
|
|
+ teleporttransition = entityplayer.findRespawnPositionAndUseSpawnBlock(!flag, TeleportTransition.DO_NOTHING, reason);
|
|
+ }
|
|
+ // Slice end
|
|
|
|
if (!flag) entityplayer.reset(); // SPIGOT-4785
|
|
- // Paper start - Add PlayerPostRespawnEvent
|
|
- if (teleporttransition == null) return entityplayer; // Early exit, mirrors belows early return for disconnected players in respawn event
|
|
- isRespawn = true;
|
|
- location = CraftLocation.toBukkit(teleporttransition.position(), teleporttransition.newLevel().getWorld(), teleporttransition.yRot(), teleporttransition.xRot());
|
|
- // Paper end - Add PlayerPostRespawnEvent
|
|
+ // Paper start - Add PlayerPostRespawnEvent
|
|
+ if (teleporttransition == null || entityplayer.connection.isDisconnected()) return entityplayer; // Early exit, mirrors belows early return for disconnected players in respawn event
|
|
+ isRespawn = true;
|
|
+ location = CraftLocation.toBukkit(teleporttransition.position(), teleporttransition.newLevel().getWorld(), teleporttransition.yRot(), teleporttransition.xRot());
|
|
+ // Paper end - Add PlayerPostRespawnEvent
|
|
} else {
|
|
teleporttransition = new TeleportTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING);
|
|
}
|
|
+
|
|
// Spigot Start
|
|
if (teleporttransition == null) { // Paper - Add PlayerPostRespawnEvent - diff on change - spigot early returns if respawn pos is null, that is how they handle disconnected player in respawn event
|
|
return entityplayer;
|