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 TypeMethodDescriptionintGets the amount of hearts to be consumed.static org.bukkit.event.HandlerListGets the static HandlerList for this event.@NotNull org.bukkit.event.HandlerListGets the list of handlers for this event.org.bukkit.inventory.ItemStackGets the heartItemStackthe player is consuming.org.bukkit.entity.PlayerGets the player who is consuming the heart item.getUser()Gets theLifestealerUserassociated with the player.booleanChecks if the event is cancelled.voidsetAmount(int amount) Sets the amount of hearts that will be added to the player after consuming the heart item.voidsetCancelled(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- theLifestealerUserassociated with the playeritemStack- theItemStackrepresenting 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 theLifestealerUserassociated with the player.- Returns:
- the
LifestealerUserassociated 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 heartItemStackthe player is consuming.- Returns:
- the heart
ItemStack
-
isCancelled
public boolean isCancelled()Checks if the event is cancelled.- Specified by:
isCancelledin 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:
setCancelledin 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:
getHandlersin 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
-