Class LifestealerPostPlayerDeathEvent

java.lang.Object
org.bukkit.event.Event
dev.chicoferreira.lifestealer.events.LifestealerPostPlayerDeathEvent

public class LifestealerPostPlayerDeathEvent extends org.bukkit.event.Event
Called when a player dies, after the hearts have been removed from the player and before the player gets banned if they have less than the minimum amount of hearts.

This event won't be called if the heart drop was restricted by a LifestealerHeartDropRestriction that produced LifestealerHeartDropAction.shouldRemoveHearts() true.

Thread-safety (WARNING): This event is called with a write lock active on the user.

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
    LifestealerPostPlayerDeathEvent(@NotNull org.bukkit.event.entity.PlayerDeathEvent deathEvent, @NotNull org.bukkit.entity.Player player, @NotNull LifestealerUser user, @Nullable org.bukkit.inventory.ItemStack itemStackToDrop, int heartsRemoved, LifestealerUserController.ChangeHeartsResult result)
    Constructs a new LifestealerPostPlayerDeathEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the result of the change of hearts.
    @NotNull org.bukkit.event.entity.PlayerDeathEvent
    Gets the death event that originated this event.
    int
    Gets the difference between the new and previous amount of hearts.
    static org.bukkit.event.HandlerList
    Gets the handler list.
    @NotNull org.bukkit.event.HandlerList
    Gets the handler list.
    @Nullable org.bukkit.inventory.ItemStack
    Returns the ItemStack to drop when the player dies.
    @NotNull org.bukkit.entity.Player
    Gets the player that died.
    int
    Gets the amount of hearts that had been removed from the player.
    Gets the user related to the player.
    boolean
    Checks if the amount of hearts of the player has changed.

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LifestealerPostPlayerDeathEvent

      public LifestealerPostPlayerDeathEvent(@NotNull @NotNull org.bukkit.event.entity.PlayerDeathEvent deathEvent, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull LifestealerUser user, @Nullable @Nullable org.bukkit.inventory.ItemStack itemStackToDrop, int heartsRemoved, @NotNull LifestealerUserController.ChangeHeartsResult result)
      Constructs a new LifestealerPostPlayerDeathEvent.
      Parameters:
      deathEvent - the death event that originated this event
      player - the player that died
      user - the user related to the player
      itemStackToDrop - the heart item to drop when the player dies
      heartsRemoved - the amount of hearts removed from the player
      result - the result of the change of hearts
  • Method Details

    • getDeathEvent

      @NotNull public @NotNull org.bukkit.event.entity.PlayerDeathEvent getDeathEvent()
      Gets the death event that originated this event. Changes to this event are not recommended. Please make sure to be sure of what you are doing.
      Returns:
      the death event that originated this event
    • getPlayer

      @NotNull public @NotNull org.bukkit.entity.Player getPlayer()
      Gets the player that died.
      Returns:
      the player that died
    • getUser

      @NotNull public @NotNull LifestealerUser getUser()
      Gets the user related to the player.
      Returns:
      the user related to the player
    • getItemStackToDrop

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getItemStackToDrop()
      Returns the ItemStack to drop when the player dies. Unless changed, the heart item is valid for consumption and contains the amount of hearts that getRemovedHearts() returns.

      This can return null if a plugin has set the heart item to drop to null.

      Returns:
      the heart ItemStack to drop when the player dies
    • getRemovedHearts

      public int getRemovedHearts()
      Gets the amount of hearts that had been removed from the player. Unless changed, this is the amount of hearts contained in the ItemStack returned by getItemStackToDrop().
      Returns:
      the amount of hearts to remove from the player when they die
    • getChangeResult

      Gets the result of the change of hearts.
      Returns:
      the result of the change of hearts
    • hasChanged

      public boolean hasChanged()
      Checks if the amount of hearts of the player has changed. This will return true if the player's hearts have changed, or false if the player's hearts have not changed (e.g. the player is already at maximum hearts). Equivalent to event.getChangeResult().hasChanged().
      Returns:
      if the amount of hearts of the player has changed
    • getDifference

      public int getDifference()
      Gets the difference between the new and previous amount of hearts. This will return 0 if the player's hearts have not changed (e.g. the player is already at maximum hearts). Equivalent to event.getResult().difference().
      Returns:
      the difference between the new and previous amount of hearts (newHearts - previousHearts)
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Gets the handler list.
      Specified by:
      getHandlers in class org.bukkit.event.Event
      Returns:
      the handler list
    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()
      Gets the handler list.
      Returns:
      the handler list