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

public class ConsumableEvent extends EnchantEffectEvent implements 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

    Constructors
    Constructor
    Description
    ConsumableEvent(@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 new ConsumableEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the consumption time in ticks.
    int
    Gets the food level change.
    static @NotNull org.bukkit.event.HandlerList
    Gets the handler list for this event type.
    @NotNull org.bukkit.event.HandlerList
     
    double
    Gets the health restored.
    @NotNull org.bukkit.inventory.ItemStack
    Gets the item being consumed.
    @NotNull org.bukkit.Material
    Gets the material of the consumed item.
    @NotNull org.bukkit.entity.Player
    Gets the player consuming the item.
    float
    Gets the saturation change.
    boolean
    Checks if the item is edible even when not hungry.
    boolean
     
    boolean
    Checks if the consumed item is a drink.
    boolean
    Checks if the consumed item is food.
    boolean
    Checks if the consumed item is a potion.
    void
    setCancelled(boolean cancelled)
     
    void
    setConsumptionTime(int consumptionTime)
    Sets the consumption time in ticks.
    void
    setFoodLevel(int foodLevel)
    Sets the food level change.
    void
    setHealthRestored(double healthRestored)
    Sets the health restored.
    void
    setSaturation(float saturation)
    Sets the saturation change.

    Methods inherited from class io.artificial.enchantments.api.event.EnchantEffectEvent

    checkCancelled, getEnchantment, getLevel, getScaledValue, isCancellable

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 new ConsumableEvent.
      Parameters:
      enchantment - the enchantment that triggered this event
      level - the level of the enchantment
      scaledValue - the scaled value from the enchantment's scaling algorithm
      player - the player consuming the item
      item - the item being consumed
      material - the material of the consumed item
      foodLevel - the food level change
      saturation - the saturation change
      healthRestored - the health restored
      consumptionTime - 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:
      isCancelled in interface org.bukkit.event.Cancellable
    • setCancelled

      public void setCancelled(boolean cancelled)
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Specified by:
      getHandlers in class EnchantEffectEvent
    • getHandlerList

      @NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()
      Gets the handler list for this event type.
      Returns:
      the handler list