Class ConsumableEvent
java.lang.Object
org.bukkit.event.Event
io.artificial.enchantments.api.event.EnchantEffectEvent
io.artificial.enchantments.api.event.ConsumableEvent
- All Implemented Interfaces:
org.bukkit.event.Cancellable
Event fired when a consumable-related enchantment effect triggers.
Carries data about the player, item, and consumption values during item consumption events. This event is cancellable.
- Since:
- 0.1.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionConsumableEvent(@NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.inventory.ItemStack item, @NotNull org.bukkit.Material material, int foodLevel, float saturation, double healthRestored, int consumptionTime) Creates a newConsumableEvent. -
Method Summary
Modifier and TypeMethodDescriptionintGets the consumption time in ticks.intGets the food level change.static @NotNull org.bukkit.event.HandlerListGets the handler list for this event type.@NotNull org.bukkit.event.HandlerListdoubleGets the health restored.@NotNull org.bukkit.inventory.ItemStackgetItem()Gets the item being consumed.@NotNull org.bukkit.MaterialGets the material of the consumed item.@NotNull org.bukkit.entity.PlayerGets the player consuming the item.floatGets the saturation change.booleanChecks if the item is edible even when not hungry.booleanbooleanisDrink()Checks if the consumed item is a drink.booleanisFood()Checks if the consumed item is food.booleanisPotion()Checks if the consumed item is a potion.voidsetCancelled(boolean cancelled) voidsetConsumptionTime(int consumptionTime) Sets the consumption time in ticks.voidsetFoodLevel(int foodLevel) Sets the food level change.voidsetHealthRestored(double healthRestored) Sets the health restored.voidsetSaturation(float saturation) Sets the saturation change.Methods inherited from class io.artificial.enchantments.api.event.EnchantEffectEvent
checkCancelled, getEnchantment, getLevel, getScaledValue, isCancellableMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
ConsumableEvent
public ConsumableEvent(@NotNull @NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull org.bukkit.Material material, int foodLevel, float saturation, double healthRestored, int consumptionTime) Creates a newConsumableEvent.- Parameters:
enchantment- the enchantment that triggered this eventlevel- the level of the enchantmentscaledValue- the scaled value from the enchantment's scaling algorithmplayer- the player consuming the itemitem- the item being consumedmaterial- the material of the consumed itemfoodLevel- the food level changesaturation- the saturation changehealthRestored- the health restoredconsumptionTime- the consumption time in ticks
-
-
Method Details
-
getPlayer
@NotNull public @NotNull org.bukkit.entity.Player getPlayer()Gets the player consuming the item.- Returns:
- the consuming player
-
getItem
@NotNull public @NotNull org.bukkit.inventory.ItemStack getItem()Gets the item being consumed.- Returns:
- the consumed item
-
getMaterial
@NotNull public @NotNull org.bukkit.Material getMaterial()Gets the material of the consumed item.- Returns:
- the material
-
getFoodLevel
public int getFoodLevel()Gets the food level change.- Returns:
- the food level
-
setFoodLevel
public void setFoodLevel(int foodLevel) Sets the food level change.- Parameters:
foodLevel- the new food level (clamped to 0-20)
-
getSaturation
public float getSaturation()Gets the saturation change.- Returns:
- the saturation value
-
setSaturation
public void setSaturation(float saturation) Sets the saturation change.- Parameters:
saturation- the new saturation (clamped to 0-foodLevel)
-
getHealthRestored
public double getHealthRestored()Gets the health restored.- Returns:
- the health restored
-
setHealthRestored
public void setHealthRestored(double healthRestored) Sets the health restored.- Parameters:
healthRestored- the new health restored (clamped to non-negative)
-
getConsumptionTime
public int getConsumptionTime()Gets the consumption time in ticks.- Returns:
- the consumption time
-
setConsumptionTime
public void setConsumptionTime(int consumptionTime) Sets the consumption time in ticks.- Parameters:
consumptionTime- the new consumption time (clamped to non-negative)
-
isFood
public boolean isFood()Checks if the consumed item is food.- Returns:
- true if food
-
isPotion
public boolean isPotion()Checks if the consumed item is a potion.- Returns:
- true if potion
-
isDrink
public boolean isDrink()Checks if the consumed item is a drink.- Returns:
- true if drink
-
isAlwaysEdible
public boolean isAlwaysEdible()Checks if the item is edible even when not hungry.- Returns:
- true if always edible
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceorg.bukkit.event.Cancellable
-
setCancelled
public void setCancelled(boolean cancelled) - Specified by:
setCancelledin interfaceorg.bukkit.event.Cancellable
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()- Specified by:
getHandlersin classEnchantEffectEvent
-
getHandlerList
@NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()Gets the handler list for this event type.- Returns:
- the handler list
-