Class PlayerIngameDeathEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
de.marcely.bedwars.api.event.player.PlayerIngameDeathEvent
All Implemented Interfaces:
ArenaEvent
Direct Known Subclasses:
PlayerKillPlayerEvent

public class PlayerIngameDeathEvent extends PlayerEvent implements ArenaEvent
Gets called when a player dies during a match
  • Constructor Details

    • PlayerIngameDeathEvent

      public PlayerIngameDeathEvent(PlayerDeathEvent bukkitEvent, Arena arena, boolean fatalDeath, Message deathMessage, Set<Player> deathMessageTargets, int deathSpectateDuration)
  • Method Details

    • getBukkitEvent

      public PlayerDeathEvent getBukkitEvent()
      Returns the event that got everything rolling and that has been used to identify the players death.
      Returns:
      The event that contains deeper info about the players death
    • getArena

      public Arena getArena()
      Returns the arena in which the player has died.
      Specified by:
      getArena in interface ArenaEvent
      Returns:
      The involved arena
    • isFatalDeath

      public boolean isFatalDeath()
      Returns whether or not the player is getting excluded due his death.
      Returns:
      If his death was fatal or not
    • setFatalDeath

      public void setFatalDeath(boolean fatalDeath)
      Set whether the player shall get excluded due his death.
      Parameters:
      fatalDeath - If his death was fatal or not
    • getDeathMessage

      public Message getDeathMessage()
      Returns the death message that'll be displayed in the chat to the players instead of the default vanilla one.

      This method never returns null. It might return an empty String with the String.length() of 0. In this case it won't display any death message to him.
      Make sure to not free the Message instance! Otherwise you might face an unexpected behaviour.

      Returns:
      The death message of his death
    • setDeathMessage

      public void setDeathMessage(Message deathMessage)
      Set the death message that'll be displayed in the chat to the players instead of the default vanilla one.

      Pass in an empty string (has a String.length() of 0). In this case it won't display any death message.

      Parameters:
      deathMessage - The new death message of his death
    • getDeathMessageTargets

      public Set<Player> getDeathMessageTargets()
      Returns all the players to whom the custom death message will be displayed to.

      This calculates it for all players on the server and not only for those inside the arena. It's legal to modify the entries of the returning Collection.

      Returns:
      All players (on the server) to whom the death message will be shown
    • addDeathMessageTarget

      public boolean addDeathMessageTarget(Player player)
      Add a player to whom the custom death message will be displayed to.

      You may add any player on the server. This does not only count for the players on the server. Using getDeathMessageTargets()#add(player) is also legal.

      Parameters:
      player - The player who shall be added
      Returns:
      false if he's already receiving it, otherwise true
    • addDeathMessageTargets

      public boolean addDeathMessageTargets(Collection<? extends Player> players)
      Add multiple players simultaneously to whom the custom death message will be displayed to.

      You may add any player on the server. This does not only count for the players on the server. Using getDeathMessageTargets()#add(players) is also legal.

      Parameters:
      players - The players who shall be added
      Returns:
      true if at least one player has been newly added
    • removeDeathMessageTarget

      public boolean removeDeathMessageTarget(Player player)
      Remove a player to whom the custom death message shall not be displayed to.

      You may remove any player on the server. This does not only count for the players on the server. Using getDeathMessageTargets()#remove(player) is also legal.

      Parameters:
      player - The player who shall be removed
      Returns:
      false if he hasn't already been receiving it, otherwise true
    • removeDeathMessageTargets

      public boolean removeDeathMessageTargets(Collection<? extends Player> players)
      Remove players to whom the custom death message shall not be displayed to.

      You may remove any player on the server. This does not only count for the players on the server. Using getDeathMessageTargets()#remove(players) is also legal.

      Parameters:
      players - The players who shall be removed
      Returns:
      true if at least one player has been removed
    • getDeathSpectateDuration

      public int getDeathSpectateDuration()
      Returns the duration in seconds in which the player will enter the spectator mode after his respawn. He has to wait this duration until he's able to respawn again.

      This returning 0 or less causes him to get respawned immediately.

      Returns:
      The duration in seconds he'll have to wait until he respawns. -1 to make him respawn immediately
    • setDeathSpectateDuration

      public void setDeathSpectateDuration(int duration)
      Set the duration in seconds in which the player will enter the spectator mode after his respawn. He has to wait this duration until he's able to respawn again.

      Setting this to 0 or less causes him to get respawned immediately.

      Parameters:
      duration - Set the duration in seconds he'll have to wait until he respawns. -1 to make him respawn immediately
    • isDeathSpectating

      public boolean isDeathSpectating()
      Returns whether the player will have to wait by spectating.

      Use setDeathSpectateDuration(int) to modify the behaviour.

      Returns:
      Whether he'll have to wait to respawn or not
    • getHandlers

      public HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      public static HandlerList getHandlerList()