Class endstone::PlayerSetSpawnEvent¶
ClassList > endstone > PlayerSetSpawnEvent
Called when a player's spawn is set, either by themselves or otherwise. More...
#include <endstone/event/player/player_set_spawn_event.h>
Inherits the following classes: endstone::Cancellable
Public Types¶
| Type | Name |
|---|---|
| enum | Cause Represents the cause of the spawn change. |
Public Functions¶
| Type | Name |
|---|---|
| ENDSTONE_EVENT (PlayerSetSpawnEvent) |
|
| PlayerSetSpawnEvent (const NotNull< Player > & player, Cause cause, std::optional< Location > location) |
|
| Cause | getCause () const Gets the cause of this event. |
| const std::optional< Location > & | getLocation () const Gets the location that the spawn is set to. |
| void | setLocation (std::optional< Location > location) Sets the location to be set as the spawn location. |
Public Functions inherited from endstone::Cancellable¶
| Type | Name |
|---|---|
| virtual void | cancel () Cancel this event. |
| virtual bool | isCancelled () override const Gets the cancellation state of this event. |
| virtual void | setCancelled (bool cancel) override Sets the cancellation state of this event. |
Public Functions inherited from endstone::ICancellable¶
| Type | Name |
|---|---|
| virtual void | cancel () = 0 Cancels this event. |
| virtual bool | isCancelled () const = 0 Gets the cancellation state of this event. |
| virtual void | setCancelled (bool cancel) = 0 Sets the cancellation state of this event. |
| virtual | ~ICancellable () = default |
Detailed Description¶
Assigning a new location through setLocation() redirects the spawn that is about to be written; cancelling leaves the respawn point untouched.
Note:
Only the location's block coordinates and dimension are written back; Bedrock does not persist yaw/pitch for a respawn point. Cancelling stops the respawn point from changing, but not the feedback around it: /spawnpoint still reports success and a respawn anchor still plays its sound and message, because neither consults the setter. The event is not fired when Bedrock clears a respawn point, so /clearspawnpoint and breaking the bed a player is bound to are both silent.
Public Types Documentation¶
enum Cause¶
Represents the cause of the spawn change.
Public Functions Documentation¶
function ENDSTONE_EVENT¶
function PlayerSetSpawnEvent¶
inline endstone::PlayerSetSpawnEvent::PlayerSetSpawnEvent (
const NotNull < Player > & player,
Cause cause,
std::optional< Location > location
)
function getCause¶
Gets the cause of this event.
Returns:
the cause
function getLocation¶
Gets the location that the spawn is set to.
Returns:
the spawn location, or std::nullopt if removing the location
function setLocation¶
Sets the location to be set as the spawn location.
Parameters:
locationthe spawn location, or std::nullopt to remove the spawn location
The documentation for this class was generated from the following file include/endstone/event/player/player_set_spawn_event.h