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

public class CombatEvent extends EnchantEffectEvent implements 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 Classes
    Modifier and Type
    Class
    Description
    static enum 
    Represents the type of combat interaction.

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    @Nullable org.bukkit.entity.LivingEntity
    Gets the attacking entity, if any.
    double
    Gets the base damage before modifiers.
    Gets the combat type.
    @NotNull org.bukkit.damage.DamageSource
    Gets the Bukkit damage source.
    double
    Gets the final damage after modifications.
    static @NotNull org.bukkit.event.HandlerList
    Gets the handler list for this event type.
    @NotNull org.bukkit.event.HandlerList
     
    @NotNull org.bukkit.entity.LivingEntity
    Gets the victim receiving damage.
    @Nullable org.bukkit.inventory.ItemStack
    Gets the weapon used in the attack, if any.
    boolean
    Checks if this is an attack event.
    boolean
     
    boolean
    Checks if this is a defense event.
    void
    setCancelled(boolean cancelled)
     
    void
    setFinalDamage(double damage)
    Sets the final damage value.

    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

    • 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 new CombatEvent.
      Parameters:
      enchantment - the enchantment that triggered this event
      level - the level of the enchantment
      scaledValue - the scaled value from the enchantment's scaling algorithm
      attacker - the attacking entity, or null for environmental damage
      victim - the victim receiving damage
      weapon - the weapon used, or null
      baseDamage - the base damage before modifiers
      damageSource - the Bukkit damage source
      type - 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

      @NotNull public @NotNull CombatEvent.CombatType 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:
      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