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.PlayerDeathEventGets the death event that originated this event.static org.bukkit.event.HandlerListGets the handler list.@NotNull org.bukkit.event.HandlerListGets the handler list.intGets the amount of hearts to remove from the player when they die.@Nullable org.bukkit.inventory.ItemStackReturns theItemStackto drop when the player dies.@NotNull org.bukkit.entity.PlayerGets the player that died.@NotNull LifestealerUsergetUser()Gets the user related to the player.booleanReturns if the event had been cancelled.voidsetCancelled(boolean cancel) Sets if the event should be cancelled.voidsetHeartsToRemove(int heartsToRemove) Sets the amount of hearts to remove from the player when they die.voidsetItemStackToDrop(@Nullable org.bukkit.inventory.ItemStack itemStackToDrop) Sets theItemStackto 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 theItemStackto 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
ItemStackthat will be dropped, so you can modify it directly to change it.If you wish to replace the
ItemStackfor otherLifestealerHeartItemuseLifestealerHeartItemManager.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
ItemStackto drop when the player dies
-
setItemStackToDrop
public void setItemStackToDrop(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStackToDrop) Sets theItemStackto 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 newItemStackcontains a different amount of hearts.If you wish to replace the
ItemStackfor otherLifestealerHeartItemuseLifestealerHeartItemManager.getItem(String),LifestealerHeartItemManager.generateItem(LifestealerHeartItem)to generate a newItemStackand set it here.Setting this to null will make the player to not drop the heart item when they die.
- Parameters:
itemStackToDrop- the heartItemStackto 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 theItemStackreturned 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:
isCancelledin 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, theItemStackreturned bygetItemStackToDrop()will not be dropped. The player will also not be banned if they have less than the minimum amount of hearts.- Specified by:
setCancelledin 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:
getHandlersin classorg.bukkit.event.Event- Returns:
- the handler list
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList()Gets the handler list.- Returns:
- the handler list
-