Interface ConsumableContext
- All Superinterfaces:
EffectContext
Context for consumable-related enchantment effects.
Provides access to player, item, food level, saturation, and health restoration data during item consumption events.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionintGets the consumption time in ticks.intGets the food level change from this item.doubleGets the health restored by this item.@NotNull org.bukkit.inventory.ItemStackgetItem()Gets the item being consumed.@NotNull org.bukkit.LocationGets the location where consumption occurred.@NotNull org.bukkit.entity.PlayerGets the player consuming the item.floatGets the saturation change from this item.booleanChecks if the item is edible even when not hungry.booleanisDrink()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.voidsetConsumptionTime(int ticks) Sets the consumption time in ticks.voidsetFoodLevel(int level) Sets the food level change.voidsetHealthRestored(double health) Sets the health restored.voidsetSaturation(float saturation) Sets the saturation change.Methods inherited from interface io.artificial.enchantments.api.context.EffectContext
getEnchantment, getLevel, getScaledValue, isCancellable, isCancelled, tryCancel
-
Method Details
-
getPlayer
@NotNull @NotNull org.bukkit.entity.Player getPlayer()Gets the player consuming the item.- Returns:
- the consuming player
-
getItem
@NotNull @NotNull org.bukkit.inventory.ItemStack getItem()Gets the item being consumed.- Returns:
- the consumed item
-
getLocation
@NotNull @NotNull org.bukkit.Location getLocation()Gets the location where consumption occurred.- Returns:
- the consumption location
-
getFoodLevel
int getFoodLevel()Gets the food level change from this item.- Returns:
- the food level
-
setFoodLevel
void setFoodLevel(int level) Sets the food level change.- Parameters:
level- the new food level
-
getSaturation
float getSaturation()Gets the saturation change from this item.- Returns:
- the saturation value
-
setSaturation
void setSaturation(float saturation) Sets the saturation change.- Parameters:
saturation- the new saturation value
-
getHealthRestored
double getHealthRestored()Gets the health restored by this item.- Returns:
- the health restored
-
setHealthRestored
void setHealthRestored(double health) Sets the health restored.- Parameters:
health- the new health restored value
-
isFood
boolean isFood()Checks if the consumed item is food.- Returns:
- true if food
-
isPotion
boolean isPotion()Checks if the consumed item is a potion.- Returns:
- true if potion
-
isDrink
boolean isDrink()Checks if the consumed item is a drink.- Returns:
- true if drink
-
isAlwaysEdible
boolean isAlwaysEdible()Checks if the item is edible even when not hungry.- Returns:
- true if always edible
-
getConsumptionTime
int getConsumptionTime()Gets the consumption time in ticks.- Returns:
- the consumption time
-
setConsumptionTime
void setConsumptionTime(int ticks) Sets the consumption time in ticks.- Parameters:
ticks- the new consumption time
-