From 83ba6295a8dd66df967c30fc7d21f970e6874b63 Mon Sep 17 00:00:00 2001 From: Pedro <3602279+Doc94@users.noreply.github.com> Date: Sat, 7 Sep 2024 15:34:03 -0400 Subject: [PATCH] Fix NPE while trying to respawn an already disconnected player (#11353) --- patches/server/Add-PlayerPostRespawnEvent.patch | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/patches/server/Add-PlayerPostRespawnEvent.patch b/patches/server/Add-PlayerPostRespawnEvent.patch index b8d7a5f2a8..3413f39798 100644 --- a/patches/server/Add-PlayerPostRespawnEvent.patch +++ b/patches/server/Add-PlayerPostRespawnEvent.patch @@ -24,12 +24,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!flag) entityplayer.reset(); // SPIGOT-4785 + // Paper start - Add PlayerPostRespawnEvent ++ if (dimensiontransition == null) return entityplayer; // Early exit, mirrors belows early return for disconnected players in respawn event + isRespawn = true; + location = CraftLocation.toBukkit(dimensiontransition.pos(), dimensiontransition.newLevel().getWorld(), dimensiontransition.yRot(), dimensiontransition.xRot()); + // Paper end - Add PlayerPostRespawnEvent } else { dimensiontransition = new DimensionTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3.ZERO, location.getYaw(), location.getPitch(), DimensionTransition.DO_NOTHING); } + // Spigot Start +- if (dimensiontransition == null) { ++ if (dimensiontransition == 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 @@ -0,0 +0,0 @@ public abstract class PlayerList { 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()));