Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/patches/server/0280-Add-PlayerPostRespawnEvent.patch

66 Zeilen
3.5 KiB
Diff

2024-06-13 22:14:13 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MisterVector <whizkid3000@hotmail.com>
Date: Fri, 26 Oct 2018 21:31:00 -0700
Subject: [PATCH] Add PlayerPostRespawnEvent
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
2024-10-27 18:11:15 +01:00
index fd1fe9a72a1d4e87b97a34fc79ab1429d31207e5..2cfc2213e3036585dc4723eecf747e1c37d53b72 100644
2024-06-13 22:14:13 +02:00
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
2024-10-27 18:11:15 +01:00
@@ -704,6 +704,10 @@ public abstract class PlayerList {
2024-06-13 22:14:13 +02:00
entityplayer1.addTag(s);
}
+ // Paper start - Add PlayerPostRespawnEvent
+ boolean isBedSpawn = false;
+ boolean isRespawn = false;
+ // Paper end - Add PlayerPostRespawnEvent
// CraftBukkit start - fire PlayerRespawnEvent
2024-10-23 15:02:51 +02:00
TeleportTransition teleporttransition;
2024-10-27 18:11:15 +01:00
@@ -711,11 +715,16 @@ public abstract class PlayerList {
2024-10-23 15:02:51 +02:00
teleporttransition = entityplayer.findRespawnPositionAndUseSpawnBlock(!flag, TeleportTransition.DO_NOTHING, reason);
2024-06-13 22:14:13 +02:00
if (!flag) entityplayer.reset(); // SPIGOT-4785
2024-10-23 15:02:51 +02:00
+ // 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
2024-06-13 22:14:13 +02:00
} else {
2024-10-23 15:02:51 +02:00
teleporttransition = new TeleportTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING);
2024-06-13 22:14:13 +02:00
}
// Spigot Start
2024-10-23 15:02:51 +02:00
- if (teleporttransition == null) {
+ 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;
}
// Spigot End
2024-10-27 18:11:15 +01:00
@@ -763,6 +772,11 @@ public abstract class PlayerList {
2024-06-13 22:14:13 +02:00
if (iblockdata.is(Blocks.RESPAWN_ANCHOR)) {
entityplayer1.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver.getRandom().nextLong()));
}
+ // Paper start - Add PlayerPostRespawnEvent
2024-10-23 15:02:51 +02:00
+ if (iblockdata.is(net.minecraft.tags.BlockTags.BEDS) && !teleporttransition.missingRespawnBlock()) {
2024-06-13 22:14:13 +02:00
+ isBedSpawn = true;
+ }
+ // Paper end - Add PlayerPostRespawnEvent
}
// Added from changeDimension
this.sendAllPlayerInfo(entityplayer); // Update health, etc...
2024-10-27 18:11:15 +01:00
@@ -784,6 +798,13 @@ public abstract class PlayerList {
2024-06-13 22:14:13 +02:00
if (entityplayer.connection.isDisconnected()) {
this.save(entityplayer);
}
+
+ // Paper start - Add PlayerPostRespawnEvent
+ if (isRespawn) {
+ cserver.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerPostRespawnEvent(entityplayer.getBukkitEntity(), location, isBedSpawn));
+ }
+ // Paper end - Add PlayerPostRespawnEvent
+
// CraftBukkit end
return entityplayer1;