Interface PlayerSpawnLocationEventWrapper


public interface PlayerSpawnLocationEventWrapper
A wrapper for both synchronous and asynchronous player spawn location events.

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 Details

    • isAsync

      boolean isAsync()
      Get whether the listener is called asynchronously.

      Equivalent to Event.isAsynchronous().

      Returns:
      true if called async, false if 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

      void setSpawnLocation(Location loc)
      Set the player's spawn location.
      Parameters:
      loc - The new spawn location
    • sendMessage

      void sendMessage(String msg)
      Sends a message to the player.

      Supports legacy color codes using.

      Parameters:
      msg - The message to send
    • register

      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 fired
      plugin - 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 fired
      plugin - Your plugin
      priority - The event priority
      Returns:
      The registered listener that you may use to unregister it later
      See Also: