Class PlayerRespawnEvent

All Implemented Interfaces:
Cancellable

public final class PlayerRespawnEvent extends PlayerEvent implements Cancellable
Called when a player respawns after death.
See Also:
  • Method Details

    • getSpawnType

      public SpawnPointType getSpawnType()
      Gets the type of the spawn point where the player wants to respawn.
      Returns:
      the respawn point type.
    • getSpawnPosition

      public Vector3f getSpawnPosition()
      Gets the spawn position.
      Returns:
      the global spawn position as a Vector3f.
    • setSpawnPosition

      public void setSpawnPosition(Vector3f position)
      Sets the spawn position of the player.
      Parameters:
      position - a Vector3f containing the global spawn coordinates.
    • setSpawnPosition

      public void setSpawnPosition(float x, float y, float z)
      Sets the spawn position of the player.
      Parameters:
      x - global X spawn coordinate.
      y - global Y spawn coordinate.
      z - global Z spawn coordinate.
    • getSpawnRotation

      public Quaternion getSpawnRotation()
      Gets the spawn rotation.
      Returns:
      the spawn rotation as a Quaternion.
    • setSpawnRotation

      public void setSpawnRotation(Quaternion rotation)
      Sets the spawn rotation of the player.
      Parameters:
      rotation - a Quaternion which describes the spawn rotation.
    • setKeepInventory

      public void setKeepInventory(boolean set)
      Setting this to true causes the player to keep his current inventory. This also enables you to change the inventory within this event, e.g if you want a certain player to respawn only with a sword (without having to change the global default spawn inventory), you can clear his inventory, then insert a sword and call this method (set it to true).
      Parameters:
      set - true to let the player keep his inventory, or false if you want him to respawn with the default spawn inventory.
    • isKeepingInventory

      public boolean isKeepingInventory()
      Gets whether or not the player will keep his inventory upon respawn. This either happens if it was set to true previously (setKeepInventory(boolean)), or if the particular player permission (general_keepinventory) is set to true.
      Returns:
      true if the player will keep his inventory upon respawn, false if he will be equipped with the default spawn inventory instead.
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Determines if the event is cancelled. If an event is cancelled, it will no longer be executed, but other plugins will still receive the event.

      Please note: If the event is threaded, cancellation has no effect, i.e the event will still be executed.
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if the event is cancelled, or false if not.
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: Cancellable
      Cancels this event. This means it will no longer be executed, but other plugins will still receive the event.

      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancel - set to true if you want to cancel this event.
      Example: Cancel "PlayerEnterAreaEvent", i.e prevent player from entering an area
      1//Listener class
      2public class PlayerListener implements Listener{
      3 @EventMethod
      4 public void onEnterArea(PlayerEnterAreaEvent evt){
      5 //Now the player will not be able to enter the area, i.e.
      6 //he will be teleported back to his old position (outside the area)
      7 evt.setCancelled(true);
      8 }
      9}