2021-06-11 12:02:28 +00: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
2022-09-12 11:31:45 +00:00
index 917aa2bd63db9a63c75267564d0c3602b0f01392..161b5d6f0d420ac7b6ed112d1b03d42c3aaec421 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2022-09-12 11:31:45 +00:00
@@ -2894,7 +2894,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
2021-06-11 12:02:28 +00:00
case PERFORM_RESPAWN:
if (this.player.wonGame) {
this.player.wonGame = false;
- this.player = this.server.getPlayerList().respawn(this.player, true);
2021-11-24 20:43:28 +00:00
+ this.player = this.server.getPlayerList().respawn(this.player, this.server.getLevel(this.player.getRespawnDimension()), true, null, true, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag.END_PORTAL); // Paper - add isEndCreditsRespawn argument
2021-06-11 12:02:28 +00: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
2022-09-26 08:02:51 +00:00
index c5aeaf5f9753933874d2d52a13cf24ff2eb2a98b..4c2c495d936cb84d85fb3e9f91e101a0fd796026 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
2022-09-01 16:51:59 +00:00
@@ -817,6 +817,12 @@ public abstract class PlayerList {
2021-06-11 12:02:28 +00:00
}
2021-11-24 20:43:28 +00:00
public ServerPlayer respawn(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation) {
2021-06-15 02:59:31 +00:00
+ // Paper start
2021-11-24 20:43:28 +00:00
+ return respawn(entityplayer, worldserver, flag, location, avoidSuffocation, new org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag[0]);
2021-06-11 12:02:28 +00:00
+ }
+
2021-11-24 20:43:28 +00:00
+ public ServerPlayer respawn(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag...respawnFlags) {
2021-06-11 12:02:28 +00:00
+ // Paper end
entityplayer.stopRiding(); // CraftBukkit
this.players.remove(entityplayer);
this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot
2022-09-01 16:51:59 +00:00
@@ -908,7 +914,7 @@ public abstract class PlayerList {
2021-06-11 12:02:28 +00:00
}
2021-06-20 19:25:59 +00:00
Player respawnPlayer = entityplayer1.getBukkitEntity();
2021-06-11 12:02:28 +00:00
- PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn); // Paper - Fix anchor respawn acting as a bed respawn from the end portal
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn, 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 02:59:31 +00:00
this.cserver.getPluginManager().callEvent(respawnEvent);
2021-06-11 12:02:28 +00:00
// Spigot Start
if (entityplayer.connection.isDisconnected()) {