Class ProjectileEvent

java.lang.Object
org.bukkit.event.Event
io.artificial.enchantments.api.event.EnchantEffectEvent
io.artificial.enchantments.api.event.ProjectileEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public class ProjectileEvent extends EnchantEffectEvent implements org.bukkit.event.Cancellable
Event fired when a projectile-related enchantment effect triggers.

Carries data about the projectile, shooter, launch location, and hit information during projectile launch or hit events. This event is 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
    ProjectileEvent(@NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull org.bukkit.entity.Projectile projectile, @Nullable org.bukkit.entity.LivingEntity shooter, @NotNull org.bukkit.Location launchLocation, @Nullable org.bukkit.inventory.ItemStack weapon, @Nullable org.bukkit.entity.Entity hitEntity, @Nullable org.bukkit.block.Block hitBlock, @Nullable org.bukkit.util.Vector hitPosition, boolean isLaunch)
    Creates a new ProjectileEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull org.bukkit.event.HandlerList
    Gets the handler list for this event type.
    @NotNull org.bukkit.event.HandlerList
     
    @Nullable org.bukkit.block.Block
    Gets the block hit by the projectile.
    @Nullable org.bukkit.entity.Entity
    Gets the entity hit by the projectile.
    @Nullable org.bukkit.util.Vector
    Gets the precise hit position.
    @NotNull org.bukkit.Location
    Gets the location where the projectile was launched.
    int
    Gets the pierce level.
    @NotNull org.bukkit.entity.Projectile
    Gets the projectile entity.
    @Nullable org.bukkit.entity.LivingEntity
    Gets the entity that shot the projectile.
    @NotNull org.bukkit.util.Vector
    Gets the projectile velocity.
    @Nullable org.bukkit.inventory.ItemStack
    Gets the weapon used to launch the projectile.
    boolean
    Checks if the projectile has gravity.
    boolean
    Checks if the projectile hit a block.
    boolean
    Checks if the projectile hit an entity.
    boolean
     
    boolean
    Checks if this is a projectile hit event.
    boolean
    Checks if this is a projectile launch event.
    void
    setCancelled(boolean cancelled)
     
    void
    setGravity(boolean gravity)
    Sets whether the projectile has gravity.
    void
    setPierceLevel(int pierceLevel)
    Sets the pierce level.
    void
    setVelocity(@NotNull org.bukkit.util.Vector velocity)
    Sets the projectile velocity.

    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

    • ProjectileEvent

      public ProjectileEvent(@NotNull @NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull @NotNull org.bukkit.entity.Projectile projectile, @Nullable @Nullable org.bukkit.entity.LivingEntity shooter, @NotNull @NotNull org.bukkit.Location launchLocation, @Nullable @Nullable org.bukkit.inventory.ItemStack weapon, @Nullable @Nullable org.bukkit.entity.Entity hitEntity, @Nullable @Nullable org.bukkit.block.Block hitBlock, @Nullable @Nullable org.bukkit.util.Vector hitPosition, boolean isLaunch)
      Creates a new ProjectileEvent.
      Parameters:
      enchantment - the enchantment that triggered this event
      level - the level of the enchantment
      scaledValue - the scaled value from the enchantment's scaling algorithm
      projectile - the projectile entity
      shooter - the entity that shot the projectile, or null
      launchLocation - the location where the projectile was launched
      weapon - the weapon used, or null
      hitEntity - the entity hit, or null
      hitBlock - the block hit, or null
      hitPosition - the precise hit position, or null
      isLaunch - true if this is a launch event, false if hit
  • Method Details

    • getProjectile

      @NotNull public @NotNull org.bukkit.entity.Projectile getProjectile()
      Gets the projectile entity.
      Returns:
      the projectile
    • getShooter

      @Nullable public @Nullable org.bukkit.entity.LivingEntity getShooter()
      Gets the entity that shot the projectile.
      Returns:
      the shooter, or null
    • getLaunchLocation

      @NotNull public @NotNull org.bukkit.Location getLaunchLocation()
      Gets the location where the projectile was launched.
      Returns:
      the launch location
    • getWeapon

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getWeapon()
      Gets the weapon used to launch the projectile.
      Returns:
      the weapon, or null
    • getHitEntity

      @Nullable public @Nullable org.bukkit.entity.Entity getHitEntity()
      Gets the entity hit by the projectile.
      Returns:
      the hit entity, or null
    • getHitBlock

      @Nullable public @Nullable org.bukkit.block.Block getHitBlock()
      Gets the block hit by the projectile.
      Returns:
      the hit block, or null
    • getHitPosition

      @Nullable public @Nullable org.bukkit.util.Vector getHitPosition()
      Gets the precise hit position.
      Returns:
      the hit position vector, or null
    • isLaunch

      public boolean isLaunch()
      Checks if this is a projectile launch event.
      Returns:
      true if launch
    • isHit

      public boolean isHit()
      Checks if this is a projectile hit event.
      Returns:
      true if hit
    • hasHitEntity

      public boolean hasHitEntity()
      Checks if the projectile hit an entity.
      Returns:
      true if entity was hit
    • hasHitBlock

      public boolean hasHitBlock()
      Checks if the projectile hit a block.
      Returns:
      true if block was hit
    • getVelocity

      @NotNull public @NotNull org.bukkit.util.Vector getVelocity()
      Gets the projectile velocity.
      Returns:
      the velocity vector
    • setVelocity

      public void setVelocity(@NotNull @NotNull org.bukkit.util.Vector velocity)
      Sets the projectile velocity.
      Parameters:
      velocity - the new velocity
    • hasGravity

      public boolean hasGravity()
      Checks if the projectile has gravity.
      Returns:
      true if gravity is enabled
    • setGravity

      public void setGravity(boolean gravity)
      Sets whether the projectile has gravity.
      Parameters:
      gravity - true to enable gravity
    • 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)
    • 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