Class LifestealerPrePlayerDeathEvent
- All Implemented Interfaces:
org.bukkit.event.Cancellable
Thread-safety (WARNING): This event is called with no active locks on the user.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result
-
Constructor Summary
ConstructorsConstructorDescriptionLifestealerPrePlayerDeathEvent
(@NotNull org.bukkit.event.entity.PlayerDeathEvent deathEvent, @NotNull org.bukkit.entity.Player player, @NotNull LifestealerUser user, @NotNull org.bukkit.inventory.ItemStack itemStackToDrop, int heartsToRemove) Constructs a new LifestealerPrePlayerDeathEvent. -
Method Summary
Modifier and TypeMethodDescription@NotNull org.bukkit.event.entity.PlayerDeathEvent
Gets the death event that originated this event.static org.bukkit.event.HandlerList
Gets the handler list.@NotNull org.bukkit.event.HandlerList
Gets the handler list.int
Gets the amount of hearts to remove from the player when they die.@Nullable org.bukkit.inventory.ItemStack
Returns theItemStack
to drop when the player dies.@NotNull org.bukkit.entity.Player
Gets the player that died.@NotNull LifestealerUser
getUser()
Gets the user related to the player.boolean
Returns if the event had been cancelled.void
setCancelled
(boolean cancel) Sets if the event should be cancelled.void
setHeartsToRemove
(int heartsToRemove) Sets the amount of hearts to remove from the player when they die.void
setItemStackToDrop
(@Nullable org.bukkit.inventory.ItemStack itemStackToDrop) Sets theItemStack
to drop when the player dies.Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
LifestealerPrePlayerDeathEvent
public LifestealerPrePlayerDeathEvent(@NotNull @NotNull org.bukkit.event.entity.PlayerDeathEvent deathEvent, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull LifestealerUser user, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStackToDrop, int heartsToRemove) Constructs a new LifestealerPrePlayerDeathEvent.- Parameters:
deathEvent
- the death event that originated this eventplayer
- the player that dieduser
- the user related to the playeritemStackToDrop
- the heart item to drop when the player diesheartsToRemove
- the amount of hearts to remove from the player
-
-
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
Gets the user related to the player.- Returns:
- the user related to the player
-
getItemStackToDrop
@Nullable public @Nullable org.bukkit.inventory.ItemStack getItemStackToDrop()Returns theItemStack
to drop when the player dies. Initially the heart item is valid for consumption and contains the amount of hearts thatgetHeartsToRemove()
returns.This is a reference to the
ItemStack
that will be dropped, so you can modify it directly to change it.If you wish to replace the
ItemStack
for otherLifestealerHeartItem
useLifestealerHeartItemManager.getItem(String)
,LifestealerHeartItemManager.generateItem(LifestealerHeartItem)
andsetItemStackToDrop(ItemStack)
.This can return null if a plugin has set the item to drop to null.
- Returns:
- the heart
ItemStack
to drop when the player dies
-
setItemStackToDrop
public void setItemStackToDrop(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStackToDrop) Sets theItemStack
to drop when the player dies.When setting a new
ItemStack
, you may need to set the amount of hearts to be removed from the player again if you wish to keep the amount of hearts consistent and the newItemStack
contains a different amount of hearts.If you wish to replace the
ItemStack
for otherLifestealerHeartItem
useLifestealerHeartItemManager.getItem(String)
,LifestealerHeartItemManager.generateItem(LifestealerHeartItem)
to generate a newItemStack
and set it here.Setting this to null will make the player to not drop the heart item when they die.
- Parameters:
itemStackToDrop
- the heartItemStack
to drop when the player dies
-
getHeartsToRemove
public int getHeartsToRemove()Gets the amount of hearts to remove from the player when they die. Unless changed, this is the amount of hearts contained in theItemStack
returned bygetItemStackToDrop()
.- Returns:
- the amount of hearts to remove from the player when they die
-
setHeartsToRemove
public void setHeartsToRemove(int heartsToRemove) Sets the amount of hearts to remove from the player when they die.- Parameters:
heartsToRemove
- the amount of hearts to remove from the player when they die
-
isCancelled
public boolean isCancelled()Returns if the event had been cancelled.- Specified by:
isCancelled
in interfaceorg.bukkit.event.Cancellable
- Returns:
- if the event is cancelled
-
setCancelled
public void setCancelled(boolean cancel) Sets if the event should be cancelled. If the event is cancelled, the player will not lose hearts, theItemStack
returned bygetItemStackToDrop()
will not be dropped. The player will also not be banned if they have less than the minimum amount of hearts.- Specified by:
setCancelled
in interfaceorg.bukkit.event.Cancellable
- Parameters:
cancel
- true if you wish to cancel this event and prevent the player from losing hearts and dropping the heart item, false otherwise
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()Gets the handler list.- Specified by:
getHandlers
in classorg.bukkit.event.Event
- Returns:
- the handler list
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList()Gets the handler list.- Returns:
- the handler list
-