Class WeaponEvent

java.lang.Object
org.bukkit.event.Event
io.artificial.enchantments.api.event.EnchantEffectEvent
io.artificial.enchantments.api.event.WeaponEvent

public class WeaponEvent extends EnchantEffectEvent
Event fired when a weapon-related enchantment effect triggers.

Carries data about the player, weapon, target, and projectile during bow, crossbow, or trident use events. This event is not 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
    WeaponEvent(@NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.inventory.ItemStack weapon, @NotNull org.bukkit.Location location, @Nullable org.bukkit.entity.LivingEntity target, @Nullable org.bukkit.entity.Projectile projectile, boolean isBow, boolean isCrossbow, boolean isTrident, boolean isShooting, boolean isThrowing, float force, boolean critical, int pierceLevel)
    Creates a new WeaponEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Gets the force of the shot.
    static @NotNull org.bukkit.event.HandlerList
    Gets the handler list for this event type.
    @NotNull org.bukkit.event.HandlerList
     
    @NotNull org.bukkit.Location
    Gets the location of the event.
    int
    Gets the pierce level.
    @NotNull org.bukkit.entity.Player
    Gets the player using the weapon.
    @Nullable org.bukkit.entity.Projectile
    Gets the projectile.
    @Nullable org.bukkit.entity.LivingEntity
    Gets the target entity.
    @NotNull org.bukkit.inventory.ItemStack
    Gets the weapon item.
    boolean
    Checks if this is a bow event.
    boolean
    Checks if this is a critical hit.
    boolean
    Checks if this is a crossbow event.
    boolean
    Checks if this is a shooting event.
    boolean
    Checks if this is a throwing event.
    boolean
    Checks if this is a trident event.
    void
    setCritical(boolean critical)
    Sets whether this is a critical hit.
    void
    setForce(float force)
    Sets the force of the shot.
    void
    setPierceLevel(int pierceLevel)
    Sets the pierce level.

    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

    • WeaponEvent

      public WeaponEvent(@NotNull @NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.inventory.ItemStack weapon, @NotNull @NotNull org.bukkit.Location location, @Nullable @Nullable org.bukkit.entity.LivingEntity target, @Nullable @Nullable org.bukkit.entity.Projectile projectile, boolean isBow, boolean isCrossbow, boolean isTrident, boolean isShooting, boolean isThrowing, float force, boolean critical, int pierceLevel)
      Creates a new WeaponEvent.
      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 using the weapon
      weapon - the weapon item
      location - the location of the event
      target - the target entity, or null
      projectile - the projectile, or null
      isBow - true if this is a bow event
      isCrossbow - true if this is a crossbow event
      isTrident - true if this is a trident event
      isShooting - true if shooting
      isThrowing - true if throwing
      force - the force of the shot (0.0-1.0)
      critical - true if critical hit
      pierceLevel - the pierce level
  • Method Details

    • getPlayer

      @NotNull public @NotNull org.bukkit.entity.Player getPlayer()
      Gets the player using the weapon.
      Returns:
      the player
    • getWeapon

      @NotNull public @NotNull org.bukkit.inventory.ItemStack getWeapon()
      Gets the weapon item.
      Returns:
      the weapon
    • getLocation

      @NotNull public @NotNull org.bukkit.Location getLocation()
      Gets the location of the event.
      Returns:
      the location
    • getTarget

      @Nullable public @Nullable org.bukkit.entity.LivingEntity getTarget()
      Gets the target entity.
      Returns:
      the target, or null
    • getProjectile

      @Nullable public @Nullable org.bukkit.entity.Projectile getProjectile()
      Gets the projectile.
      Returns:
      the projectile, or null
    • isBow

      public boolean isBow()
      Checks if this is a bow event.
      Returns:
      true if bow
    • isCrossbow

      public boolean isCrossbow()
      Checks if this is a crossbow event.
      Returns:
      true if crossbow
    • isTrident

      public boolean isTrident()
      Checks if this is a trident event.
      Returns:
      true if trident
    • isShooting

      public boolean isShooting()
      Checks if this is a shooting event.
      Returns:
      true if shooting
    • isThrowing

      public boolean isThrowing()
      Checks if this is a throwing event.
      Returns:
      true if throwing
    • getForce

      public float getForce()
      Gets the force of the shot.
      Returns:
      the force (0.0-1.0)
    • setForce

      public void setForce(float force)
      Sets the force of the shot.
      Parameters:
      force - the new force (clamped to 0.0-1.0)
    • isCritical

      public boolean isCritical()
      Checks if this is a critical hit.
      Returns:
      true if critical
    • setCritical

      public void setCritical(boolean critical)
      Sets whether this is a critical hit.
      Parameters:
      critical - true for critical hit
    • getPierceLevel

      public int getPierceLevel()
      Gets the pierce level.
      Returns:
      the pierce level
    • setPierceLevel

      public void setPierceLevel(int pierceLevel)
      Sets the pierce level.
      Parameters:
      pierceLevel - the new pierce level (clamped to non-negative)
    • 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