2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2024-01-19 17:54:05 +01:00
|
|
|
From: HexedHero <6012891+HexedHero@users.noreply.github.com>
|
|
|
|
Date: Fri, 23 Apr 2021 22:42:42 +0100
|
|
|
|
Subject: [PATCH] Expand PlayerRespawnEvent, fix passed parameter issues
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2024-01-19 17:54:05 +01:00
|
|
|
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2024-01-19 17:54:05 +01:00
|
|
|
index d58d0748e218349fca1927263ad986ca824d4bda..8a6d9ae5b0735884a39fa2ded6f1d94909043eb7 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2023-12-29 01:50:06 +01:00
|
|
|
@@ -2644,7 +2644,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
2021-06-11 14:02:28 +02:00
|
|
|
case PERFORM_RESPAWN:
|
|
|
|
if (this.player.wonGame) {
|
|
|
|
this.player.wonGame = false;
|
2023-04-10 10:03:36 +02:00
|
|
|
- this.player = this.server.getPlayerList().respawn(this.player, true, RespawnReason.END_PORTAL);
|
2024-01-19 17:54:05 +01:00
|
|
|
+ this.player = this.server.getPlayerList().respawn(this.player, this.server.getLevel(this.player.getRespawnDimension()), true, null, true, RespawnReason.END_PORTAL, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag.END_PORTAL); // Paper - Expand PlayerRespawnEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
|
|
|
|
} else {
|
|
|
|
if (this.player.getHealth() > 0.0F) {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2024-01-19 17:54:05 +01:00
|
|
|
index 5c63a7719b2a4a4bb2c64d460b007d2976cbdbf9..a622d91ecdea6ab4deaf0ef4ae90cba71c49b319 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2024-01-16 19:27:39 +01:00
|
|
|
@@ -781,6 +781,12 @@ public abstract class PlayerList {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2023-04-10 10:03:36 +02:00
|
|
|
public ServerPlayer respawn(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation, RespawnReason reason) {
|
2024-01-19 17:54:05 +01:00
|
|
|
+ // Paper start - Expand PlayerRespawnEvent
|
2023-04-10 10:03:36 +02:00
|
|
|
+ return respawn(entityplayer, worldserver, flag, location, avoidSuffocation, reason, new org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag[0]);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
2023-04-10 10:03:36 +02:00
|
|
|
+ public ServerPlayer respawn(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation, RespawnReason reason, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag...respawnFlags) {
|
2024-01-19 17:54:05 +01:00
|
|
|
+ // Paper end - Expand PlayerRespawnEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
entityplayer.stopRiding(); // CraftBukkit
|
|
|
|
this.players.remove(entityplayer);
|
|
|
|
this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot
|
2024-01-19 17:54:05 +01:00
|
|
|
@@ -822,6 +828,7 @@ public abstract class PlayerList {
|
|
|
|
|
|
|
|
// Paper start
|
|
|
|
boolean isBedSpawn = false;
|
|
|
|
+ boolean isAnchorSpawn = false; // Paper - Fix PlayerRespawnEvent
|
|
|
|
boolean isRespawn = false;
|
|
|
|
boolean isLocAltered = false; // Paper - Fix SPIGOT-5989
|
|
|
|
// Paper end
|
|
|
|
@@ -842,6 +849,7 @@ public abstract class PlayerList {
|
|
|
|
if (optional.isPresent()) {
|
|
|
|
BlockState iblockdata = worldserver1.getBlockState(blockposition);
|
|
|
|
boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR);
|
|
|
|
+ isAnchorSpawn = flag3; // Paper - Fix PlayerRespawnEvent
|
|
|
|
Vec3 vec3d = (Vec3) optional.get();
|
|
|
|
float f1;
|
|
|
|
|
|
|
|
@@ -870,7 +878,7 @@ public abstract class PlayerList {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2021-06-20 21:25:59 +02:00
|
|
|
Player respawnPlayer = entityplayer1.getBukkitEntity();
|
2024-01-19 17:54:05 +01:00
|
|
|
- PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2, reason);
|
|
|
|
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn, reason, com.google.common.collect.ImmutableSet.<org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag>builder().add(respawnFlags)); // Paper - PlayerRespawnEvent changes
|
2021-06-15 04:59:31 +02:00
|
|
|
this.cserver.getPluginManager().callEvent(respawnEvent);
|
2021-06-11 14:02:28 +02:00
|
|
|
// Spigot Start
|
|
|
|
if (entityplayer.connection.isDisconnected()) {
|