Interface PlayerSpawnLocationEventWrapper
Paper introduced AsyncPlayerSpawnLocationEvent in version 1.21.9
that runs asynchronously when a player spawns, with the goal of replacing
Spigot's PlayerSpawnLocationEvent.
This class aims to prefer paper's async solution when available, while still maintaining compatibility with Spigot servers by falling back to the synchronous event.
To make it clear: The event is always called async on paper 1.21.9+ servers, and always sync on all spigot servers and paper versions below 1.21.9.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGet the name of the player spawning.Get the UUID of the player spawning.Get the player's spawn location.booleanisAsync()Get whether the listener is called asynchronously.static RegisteredListenerregister(Consumer<PlayerSpawnLocationEventWrapper> handler, Plugin plugin) Creates and registers a new listener for player spawn location events.static RegisteredListenerregister(Consumer<PlayerSpawnLocationEventWrapper> handler, Plugin plugin, EventPriority priority) Creates and registers a new listener for player spawn location events.voidsendMessage(String msg) Sends a message to the player.voidsetSpawnLocation(Location loc) Set the player's spawn location.
-
Method Details
-
isAsync
boolean isAsync()Get whether the listener is called asynchronously.Equivalent to
Event.isAsynchronous().- Returns:
trueif called async,falseif called sync
-
getPlayerUUID
UUID getPlayerUUID()Get the UUID of the player spawning.Equivalent to
Entity.getUniqueId().- Returns:
- The player's UUID
-
getPlayerName
String getPlayerName()Get the name of the player spawning.Equivalent to
HumanEntity.getName().- Returns:
- The player's name
-
getSpawnLocation
Location getSpawnLocation()Get the player's spawn location.- Returns:
- The spawn location
-
setSpawnLocation
Set the player's spawn location.- Parameters:
loc- The new spawn location
-
sendMessage
Sends a message to the player.Supports legacy color codes using.
- Parameters:
msg- The message to send
-
register
static RegisteredListener register(Consumer<PlayerSpawnLocationEventWrapper> handler, Plugin plugin) Creates and registers a new listener for player spawn location events.The listener will be registered using Spigot's/Paper's regular event pipeline for the coressponding event type (sync or async).
The listener will be registered with normal event priority.
- Parameters:
handler- The handler that will be called when the event is firedplugin- Your plugin- Returns:
- The registered listener that you may use to unregister it later
- See Also:
-
register
static RegisteredListener register(Consumer<PlayerSpawnLocationEventWrapper> handler, Plugin plugin, EventPriority priority) Creates and registers a new listener for player spawn location events.The listener will be registered using Spigot's/Paper's regular event pipeline for the coressponding event type (sync or async).
- Parameters:
handler- The handler that will be called when the event is firedplugin- Your pluginpriority- The event priority- Returns:
- The registered listener that you may use to unregister it later
- See Also:
-