2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 22 Apr 2021 17:17:47 -0700
Subject: [PATCH] add RespawnFlags to PlayerRespawnEvent
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2023-09-23 01:58:19 +02:00
index fe0d6841b6ad76fc4a8cf8181393a9707a98423d..73ea4907e81d7fd7830b3a9a368c88ac903428bb 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-09-22 22:13:57 +02:00
@@ -2628,7 +2628,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);
+ 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 - add isEndCreditsRespawn argument
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
2023-09-22 22:13:57 +02:00
index 11b44bf31cc0feae3c568bf100801633c0b34906..8d7e99a331b21f2efbb60936974395b9c12ad5d6 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
2023-09-22 07:41:27 +02:00
@@ -764,6 +764,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) {
2021-06-15 04:59:31 +02:00
+ // Paper start
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) {
2021-06-11 14:02:28 +02:00
+ // Paper end
entityplayer.stopRiding(); // CraftBukkit
this.players.remove(entityplayer);
this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot
2023-09-22 07:41:27 +02:00
@@ -855,7 +861,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();
2023-04-10 10:03:36 +02:00
- PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn, reason); // Paper - Fix anchor respawn acting as a bed respawn from the end portal
+ 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 - Fix anchor respawn acting as a bed respawn from the end portal
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()) {