Class LifestealerPreConsumeHeartEvent
java.lang.Object
org.bukkit.event.Event
dev.chicoferreira.lifestealer.events.LifestealerPreConsumeHeartEvent
- All Implemented Interfaces:
org.bukkit.event.Cancellable
public class LifestealerPreConsumeHeartEvent
extends org.bukkit.event.Event
implements org.bukkit.event.Cancellable
Event that is triggered before a player consumes a heart item that you can cancel.
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
ConstructorsConstructorDescriptionLifestealerPreConsumeHeartEvent
(org.bukkit.entity.Player player, LifestealerUser user, org.bukkit.inventory.ItemStack itemStack, int amount) Constructs a new LifestealerPreConsumeHeartEvent. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the amount of hearts to be consumed.static org.bukkit.event.HandlerList
Gets the static HandlerList for this event.@NotNull org.bukkit.event.HandlerList
Gets the list of handlers for this event.org.bukkit.inventory.ItemStack
Gets the heartItemStack
the player is consuming.org.bukkit.entity.Player
Gets the player who is consuming the heart item.getUser()
Gets theLifestealerUser
associated with the player.boolean
Checks if the event is cancelled.void
setAmount
(int amount) Sets the amount of hearts that will be added to the player after consuming the heart item.void
setCancelled
(boolean cancel) Sets the cancellation state of the event.Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
LifestealerPreConsumeHeartEvent
public LifestealerPreConsumeHeartEvent(org.bukkit.entity.Player player, LifestealerUser user, org.bukkit.inventory.ItemStack itemStack, int amount) Constructs a new LifestealerPreConsumeHeartEvent.- Parameters:
player
- the player who is consuming the heart itemuser
- theLifestealerUser
associated with the playeritemStack
- theItemStack
representing the heart itemamount
- the amount of hearts to be consumed (the amount of hearts the item contains)
-
-
Method Details
-
getPlayer
public org.bukkit.entity.Player getPlayer()Gets the player who is consuming the heart item.- Returns:
- the player
-
getUser
Gets theLifestealerUser
associated with the player.- Returns:
- the
LifestealerUser
associated with the player
-
getAmount
public int getAmount()Gets the amount of hearts to be consumed. Unless changed bysetAmount(int)
, this is the amount of hearts the item contains.- Returns:
- the amount of hearts
-
setAmount
public void setAmount(int amount) Sets the amount of hearts that will be added to the player after consuming the heart item. Initially this is the amount of hearts the item contains.- Parameters:
amount
- the new amount of hearts
-
getItemStack
public org.bukkit.inventory.ItemStack getItemStack()Gets the heartItemStack
the player is consuming.- Returns:
- the heart
ItemStack
-
isCancelled
public boolean isCancelled()Checks if the event is cancelled.- Specified by:
isCancelled
in interfaceorg.bukkit.event.Cancellable
- Returns:
- true if the event is cancelled, false otherwise
-
setCancelled
public void setCancelled(boolean cancel) Sets the cancellation state of the event. If the event is cancelled, the item will not be deducted from the player's inventory and the hearts will not be added to the player.- Specified by:
setCancelled
in interfaceorg.bukkit.event.Cancellable
- Parameters:
cancel
- true to cancel the event, false to uncancel
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()Gets the list of handlers for this event.- Specified by:
getHandlers
in classorg.bukkit.event.Event
- Returns:
- the HandlerList
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList()Gets the static HandlerList for this event.- Returns:
- the HandlerList
-