Interface ProjectileContext
- All Superinterfaces:
EffectContext
Context for projectile-related enchantment effects.
Provides access to projectile, shooter, launch location, hit data, and projectile physics during projectile launch and hit events.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescription@Nullable org.bukkit.block.BlockGets the block hit by the projectile, if any.@Nullable org.bukkit.entity.EntityGets the entity hit by the projectile, if any.@Nullable org.bukkit.util.VectorGets the exact position where the projectile hit.@NotNull org.bukkit.LocationGets the location where the projectile was launched.intGets the current 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 current projectile velocity.@NotNull org.bukkit.inventory.ItemStackGets the weapon used to launch the projectile.booleanChecks if gravity affects the projectile.booleanChecks if the projectile hit a block.booleanChecks if the projectile hit an entity.booleanisHit()Checks if this is a hit event.booleanisLaunch()Checks if this is a launch event.voidsetGravity(boolean gravity) Sets whether gravity affects the projectile.voidsetPierceLevel(int level) Sets the pierce level for this projectile.voidsetVelocity(@NotNull org.bukkit.util.Vector velocity) Sets the projectile velocity.Methods inherited from interface io.artificial.enchantments.api.context.EffectContext
getEnchantment, getLevel, getScaledValue, isCancellable, isCancelled, tryCancel
-
Method Details
-
getProjectile
@NotNull @NotNull org.bukkit.entity.Projectile getProjectile()Gets the projectile entity.- Returns:
- the projectile
-
getShooter
@Nullable @Nullable org.bukkit.entity.LivingEntity getShooter()Gets the entity that shot the projectile.- Returns:
- the shooter, or null if launched by dispenser or other source
-
getLaunchLocation
@NotNull @NotNull org.bukkit.Location getLaunchLocation()Gets the location where the projectile was launched.- Returns:
- the launch location
-
getWeapon
@NotNull @NotNull org.bukkit.inventory.ItemStack getWeapon()Gets the weapon used to launch the projectile.- Returns:
- the weapon item
-
getHitEntity
@Nullable @Nullable org.bukkit.entity.Entity getHitEntity()Gets the entity hit by the projectile, if any.- Returns:
- the hit entity, or null
-
getHitBlock
@Nullable @Nullable org.bukkit.block.Block getHitBlock()Gets the block hit by the projectile, if any.- Returns:
- the hit block, or null
-
getHitPosition
@Nullable @Nullable org.bukkit.util.Vector getHitPosition()Gets the exact position where the projectile hit.- Returns:
- the hit position, or null
-
hasHitEntity
boolean hasHitEntity()Checks if the projectile hit an entity.- Returns:
- true if hit entity
-
hasHitBlock
boolean hasHitBlock()Checks if the projectile hit a block.- Returns:
- true if hit block
-
isLaunch
boolean isLaunch()Checks if this is a launch event.- Returns:
- true if launching
-
isHit
boolean isHit()Checks if this is a hit event.- Returns:
- true if hitting
-
setVelocity
void setVelocity(@NotNull @NotNull org.bukkit.util.Vector velocity) Sets the projectile velocity.- Parameters:
velocity- the new velocity vector
-
getVelocity
@NotNull @NotNull org.bukkit.util.Vector getVelocity()Gets the current projectile velocity.- Returns:
- the velocity vector
-
setGravity
void setGravity(boolean gravity) Sets whether gravity affects the projectile.- Parameters:
gravity- true for gravity
-
hasGravity
boolean hasGravity()Checks if gravity affects the projectile.- Returns:
- true if has gravity
-
setPierceLevel
void setPierceLevel(int level) Sets the pierce level for this projectile.- Parameters:
level- the pierce level
-
getPierceLevel
int getPierceLevel()Gets the current pierce level.- Returns:
- the pierce level
-