Interface EffectContext
- All Known Subinterfaces:
CombatContext,ConsumableContext,FishingContext,InteractionContext,ItemContext,ProjectileContext,TickContext,ToolContext,WeaponContext
public interface EffectContext
Base interface for all effect contexts.
Context objects are passed to EnchantmentEffectHandler
methods and contain all data relevant to the triggering game event. They provide:
- Enchantment definition and level
- Scaled value calculated by the enchantment's formula
- Cancellation support (for cancellable events)
Cancellation:
Contexts that wrap cancellable Bukkit events implement Cancellable.
Use tryCancel() to attempt cancellation, or isCancelled()
to check status. Cancellation propagates back to the original Bukkit event.
- Since:
- 0.1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@NotNull EnchantmentDefinitionGets the enchantment definition that triggered this effect.intgetLevel()Gets the enchantment level applied to the item.doubleGets the scaled value calculated from the enchantment level.booleanChecks if this context supports cancellation.default booleanChecks if the underlying event has been cancelled.default booleanAttempts to cancel the underlying event.
-
Method Details
-
getEnchantment
Gets the enchantment definition that triggered this effect.- Returns:
- the enchantment definition (never null)
- Since:
- 0.1.0
-
getLevel
int getLevel()Gets the enchantment level applied to the item.- Returns:
- the enchantment level (>= 1)
- Since:
- 0.1.0
-
getScaledValue
double getScaledValue()Gets the scaled value calculated from the enchantment level.This is the result of applying the enchantment's
LevelScalingformula to the current level.- Returns:
- the scaled value
- Since:
- 0.1.0
-
isCancellable
boolean isCancellable()Checks if this context supports cancellation.- Returns:
- true if this context implements
Cancellable - Since:
- 0.1.0
-
tryCancel
default boolean tryCancel()Attempts to cancel the underlying event.Returns false if the event is not cancellable. Check
isCancellable()before calling if cancellation status is uncertain.- Returns:
- true if cancellation was successful
- Since:
- 0.1.0
-
isCancelled
default boolean isCancelled()Checks if the underlying event has been cancelled.- Returns:
- true if cancellable and cancelled
- Since:
- 0.1.0
-