Class CombatEvent
java.lang.Object
org.bukkit.event.Event
io.artificial.enchantments.api.event.EnchantEffectEvent
io.artificial.enchantments.api.event.CombatEvent
- All Implemented Interfaces:
org.bukkit.event.Cancellable
Event fired when a combat-related enchantment effect triggers.
Carries data about the attacker, victim, weapon, and damage values during entity damage events. This event is cancellable.
- Since:
- 0.1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents the type of combat interaction.Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionCombatEvent(@NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @Nullable org.bukkit.entity.LivingEntity attacker, @NotNull org.bukkit.entity.LivingEntity victim, @Nullable org.bukkit.inventory.ItemStack weapon, double baseDamage, @NotNull org.bukkit.damage.DamageSource damageSource, @NotNull CombatEvent.CombatType type) Creates a newCombatEvent. -
Method Summary
Modifier and TypeMethodDescription@Nullable org.bukkit.entity.LivingEntityGets the attacking entity, if any.doubleGets the base damage before modifiers.@NotNull CombatEvent.CombatTypeGets the combat type.@NotNull org.bukkit.damage.DamageSourceGets the Bukkit damage source.doubleGets the final damage after modifications.static @NotNull org.bukkit.event.HandlerListGets the handler list for this event type.@NotNull org.bukkit.event.HandlerList@NotNull org.bukkit.entity.LivingEntityGets the victim receiving damage.@Nullable org.bukkit.inventory.ItemStackGets the weapon used in the attack, if any.booleanisAttack()Checks if this is an attack event.booleanbooleanChecks if this is a defense event.voidsetCancelled(boolean cancelled) voidsetFinalDamage(double damage) Sets the final damage value.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
-
CombatEvent
public CombatEvent(@NotNull @NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @Nullable @Nullable org.bukkit.entity.LivingEntity attacker, @NotNull @NotNull org.bukkit.entity.LivingEntity victim, @Nullable @Nullable org.bukkit.inventory.ItemStack weapon, double baseDamage, @NotNull @NotNull org.bukkit.damage.DamageSource damageSource, @NotNull @NotNull CombatEvent.CombatType type) Creates a newCombatEvent.- Parameters:
enchantment- the enchantment that triggered this eventlevel- the level of the enchantmentscaledValue- the scaled value from the enchantment's scaling algorithmattacker- the attacking entity, or null for environmental damagevictim- the victim receiving damageweapon- the weapon used, or nullbaseDamage- the base damage before modifiersdamageSource- the Bukkit damage sourcetype- the combat type
-
-
Method Details
-
getAttacker
@Nullable public @Nullable org.bukkit.entity.LivingEntity getAttacker()Gets the attacking entity, if any.- Returns:
- the attacker, or null for environmental damage
-
getVictim
@NotNull public @NotNull org.bukkit.entity.LivingEntity getVictim()Gets the victim receiving damage.- Returns:
- the victim entity
-
getWeapon
@Nullable public @Nullable org.bukkit.inventory.ItemStack getWeapon()Gets the weapon used in the attack, if any.- Returns:
- the weapon item, or null
-
getBaseDamage
public double getBaseDamage()Gets the base damage before modifiers.- Returns:
- the base damage value
-
getFinalDamage
public double getFinalDamage()Gets the final damage after modifications.- Returns:
- the final damage value
-
setFinalDamage
public void setFinalDamage(double damage) Sets the final damage value.- Parameters:
damage- the new damage value (clamped to non-negative)
-
getDamageSource
@NotNull public @NotNull org.bukkit.damage.DamageSource getDamageSource()Gets the Bukkit damage source.- Returns:
- the damage source
-
getCombatType
Gets the combat type.- Returns:
- the combat type
-
isAttack
public boolean isAttack()Checks if this is an attack event.- Returns:
- true if attack
-
isDefense
public boolean isDefense()Checks if this is a defense event.- Returns:
- true if defense or shield block
-
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
-