-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17d76ae
commit 2436b63
Showing
7 changed files
with
128 additions
and
115 deletions.
There are no files selected for viewing
32 changes: 11 additions & 21 deletions
32
paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerPostRespawnEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
paper-api/src/main/java/io/papermc/paper/event/player/AbstractRespawnEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package io.papermc.paper.event.player; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.player.PlayerEvent; | ||
import org.bukkit.event.player.PlayerRespawnEvent; | ||
import org.jspecify.annotations.NullMarked; | ||
import java.util.Set; | ||
|
||
@NullMarked | ||
public abstract class AbstractRespawnEvent extends PlayerEvent { | ||
|
||
protected Location respawnLocation; | ||
private final boolean isBedSpawn; | ||
private final boolean isAnchorSpawn; | ||
private final PlayerRespawnEvent.RespawnReason respawnReason; | ||
private final Set<PlayerRespawnEvent.RespawnFlag> respawnFlags; | ||
|
||
protected AbstractRespawnEvent( | ||
final Player respawnPlayer, final Location respawnLocation, final boolean isBedSpawn, | ||
final boolean isAnchorSpawn, final PlayerRespawnEvent.RespawnReason respawnReason | ||
) { | ||
super(respawnPlayer); | ||
this.respawnLocation = respawnLocation; | ||
this.isBedSpawn = isBedSpawn; | ||
this.isAnchorSpawn = isAnchorSpawn; | ||
this.respawnReason = respawnReason; | ||
ImmutableSet.Builder<PlayerRespawnEvent.RespawnFlag> builder = ImmutableSet.builder(); | ||
if (respawnReason == PlayerRespawnEvent.RespawnReason.END_PORTAL) builder.add(PlayerRespawnEvent.RespawnFlag.END_PORTAL); | ||
if (this.isBedSpawn) builder.add(PlayerRespawnEvent.RespawnFlag.BED_SPAWN); | ||
if (this.isAnchorSpawn) builder.add(PlayerRespawnEvent.RespawnFlag.ANCHOR_SPAWN); | ||
this.respawnFlags = builder.build(); | ||
} | ||
|
||
/** | ||
* Gets the current respawn location | ||
* | ||
* @return the current respawn location | ||
*/ | ||
public Location getRespawnLocation() { | ||
return this.respawnLocation.clone(); | ||
} | ||
|
||
/** | ||
* Gets whether the respawn location is the player's bed. | ||
* | ||
* @return {@code true} if the respawn location is the player's bed. | ||
*/ | ||
public boolean isBedSpawn() { | ||
return this.isBedSpawn; | ||
} | ||
|
||
/** | ||
* Gets whether the respawn location is the player's respawn anchor. | ||
* | ||
* @return {@code true} if the respawn location is the player's respawn anchor. | ||
*/ | ||
public boolean isAnchorSpawn() { | ||
return this.isAnchorSpawn; | ||
} | ||
|
||
/** | ||
* Gets the reason this respawn event was called. | ||
* | ||
* @return the reason the event was called. | ||
*/ | ||
public PlayerRespawnEvent.RespawnReason getRespawnReason() { | ||
return this.respawnReason; | ||
} | ||
|
||
/** | ||
* Gets the set of flags that apply to this respawn. | ||
* | ||
* @return an immutable set of the flags that apply to this respawn | ||
* @deprecated in favour of {@link #getRespawnReason()}/{@link #isBedSpawn}/{@link #isAnchorSpawn()} | ||
*/ | ||
@Deprecated | ||
public Set<PlayerRespawnEvent.RespawnFlag> getRespawnFlags() { | ||
return this.respawnFlags; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.