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
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
ConstructorsConstructorDescriptionProjectileEvent(@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 newProjectileEvent. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull org.bukkit.event.HandlerListGets the handler list for this event type.@NotNull org.bukkit.event.HandlerList@Nullable org.bukkit.block.BlockGets the block hit by the projectile.@Nullable org.bukkit.entity.EntityGets the entity hit by the projectile.@Nullable org.bukkit.util.VectorGets the precise hit position.@NotNull org.bukkit.LocationGets the location where the projectile was launched.intGets the pierce level.@NotNull org.bukkit.entity.ProjectileGets the projectile entity.@Nullable org.bukkit.entity.LivingEntityGets the entity that shot the projectile.@NotNull org.bukkit.util.VectorGets the projectile velocity.@Nullable org.bukkit.inventory.ItemStackGets the weapon used to launch the projectile.booleanChecks if the projectile has gravity.booleanChecks if the projectile hit a block.booleanChecks if the projectile hit an entity.booleanbooleanisHit()Checks if this is a projectile hit event.booleanisLaunch()Checks if this is a projectile launch event.voidsetCancelled(boolean cancelled) voidsetGravity(boolean gravity) Sets whether the projectile has gravity.voidsetPierceLevel(int pierceLevel) Sets the pierce level.voidsetVelocity(@NotNull org.bukkit.util.Vector velocity) Sets the projectile velocity.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
-
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 newProjectileEvent.- Parameters:
enchantment- the enchantment that triggered this eventlevel- the level of the enchantmentscaledValue- the scaled value from the enchantment's scaling algorithmprojectile- the projectile entityshooter- the entity that shot the projectile, or nulllaunchLocation- the location where the projectile was launchedweapon- the weapon used, or nullhitEntity- the entity hit, or nullhitBlock- the block hit, or nullhitPosition- the precise hit position, or nullisLaunch- 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:
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
-