mirror of
https://github.com/PaperMC/Paper.git
synced 2025-05-19 05:30:23 -07:00
Add PlayerRespawnEvent#isMissingRespawnBlock (#12422)
This commit is contained in:
parent
ed322043d0
commit
6b4ad08259
@ -21,6 +21,7 @@ public class PlayerRespawnEvent extends PlayerEvent {
|
|||||||
|
|
||||||
private final boolean isBedSpawn;
|
private final boolean isBedSpawn;
|
||||||
private final boolean isAnchorSpawn;
|
private final boolean isAnchorSpawn;
|
||||||
|
private final boolean missingRespawnBlock;
|
||||||
private final RespawnReason respawnReason;
|
private final RespawnReason respawnReason;
|
||||||
private final Set<RespawnFlag> respawnFlags;
|
private final Set<RespawnFlag> respawnFlags;
|
||||||
private Location respawnLocation;
|
private Location respawnLocation;
|
||||||
@ -40,16 +41,17 @@ public class PlayerRespawnEvent extends PlayerEvent {
|
|||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public PlayerRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnLocation, final boolean isBedSpawn, final boolean isAnchorSpawn, @NotNull final RespawnReason respawnReason) {
|
public PlayerRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnLocation, final boolean isBedSpawn, final boolean isAnchorSpawn, @NotNull final RespawnReason respawnReason) {
|
||||||
this(respawnPlayer, respawnLocation, isBedSpawn, isAnchorSpawn, respawnReason, com.google.common.collect.ImmutableSet.builder());
|
this(respawnPlayer, respawnLocation, isBedSpawn, isAnchorSpawn, false, respawnReason, com.google.common.collect.ImmutableSet.builder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public PlayerRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnLocation, final boolean isBedSpawn, final boolean isAnchorSpawn, @NotNull final RespawnReason respawnReason, @NotNull final com.google.common.collect.ImmutableSet.Builder<org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag> respawnFlags) {
|
public PlayerRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnLocation, final boolean isBedSpawn, final boolean isAnchorSpawn, final boolean missingRespawnBlock, @NotNull final RespawnReason respawnReason, @NotNull final com.google.common.collect.ImmutableSet.Builder<org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag> respawnFlags) {
|
||||||
super(respawnPlayer);
|
super(respawnPlayer);
|
||||||
this.respawnLocation = respawnLocation;
|
this.respawnLocation = respawnLocation;
|
||||||
this.isBedSpawn = isBedSpawn;
|
this.isBedSpawn = isBedSpawn;
|
||||||
this.isAnchorSpawn = isAnchorSpawn;
|
this.isAnchorSpawn = isAnchorSpawn;
|
||||||
this.respawnReason = respawnReason;
|
this.respawnReason = respawnReason;
|
||||||
|
this.missingRespawnBlock = missingRespawnBlock;
|
||||||
if (this.isBedSpawn) { respawnFlags.add(RespawnFlag.BED_SPAWN); }
|
if (this.isBedSpawn) { respawnFlags.add(RespawnFlag.BED_SPAWN); }
|
||||||
if (this.isAnchorSpawn) { respawnFlags.add(RespawnFlag.ANCHOR_SPAWN); }
|
if (this.isAnchorSpawn) { respawnFlags.add(RespawnFlag.ANCHOR_SPAWN); }
|
||||||
this.respawnFlags = respawnFlags.build();
|
this.respawnFlags = respawnFlags.build();
|
||||||
@ -95,6 +97,19 @@ public class PlayerRespawnEvent extends PlayerEvent {
|
|||||||
return this.isAnchorSpawn;
|
return this.isAnchorSpawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether the player is missing a valid respawn block.
|
||||||
|
* <p>
|
||||||
|
* This will occur if the players respawn block is obstructed,
|
||||||
|
* or it is the first death after it was either destroyed or
|
||||||
|
* in case of a respawn anchor, ran out of charges.
|
||||||
|
*
|
||||||
|
* @return whether the player is missing a valid respawn block
|
||||||
|
*/
|
||||||
|
public boolean isMissingRespawnBlock() {
|
||||||
|
return this.missingRespawnBlock;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the reason this respawn event was called.
|
* Gets the reason this respawn event was called.
|
||||||
*
|
*
|
||||||
|
@ -491,7 +491,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -914,23 +_,81 @@
|
@@ -914,23 +_,82 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPvpAllowed() {
|
private boolean isPvpAllowed() {
|
||||||
@ -550,6 +550,7 @@
|
|||||||
+ location,
|
+ location,
|
||||||
+ isBedSpawn,
|
+ isBedSpawn,
|
||||||
+ isAnchorSpawn,
|
+ isAnchorSpawn,
|
||||||
|
+ teleportTransition.missingRespawnBlock(),
|
||||||
+ respawnReason,
|
+ respawnReason,
|
||||||
+ builder
|
+ builder
|
||||||
+ );
|
+ );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user