Class WeaponEvent
java.lang.Object
org.bukkit.event.Event
io.artificial.enchantments.api.event.EnchantEffectEvent
io.artificial.enchantments.api.event.WeaponEvent
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
ConstructorsConstructorDescriptionWeaponEvent(@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 newWeaponEvent. -
Method Summary
Modifier and TypeMethodDescriptionfloatgetForce()Gets the force of the shot.static @NotNull org.bukkit.event.HandlerListGets the handler list for this event type.@NotNull org.bukkit.event.HandlerList@NotNull org.bukkit.LocationGets the location of the event.intGets the pierce level.@NotNull org.bukkit.entity.PlayerGets the player using the weapon.@Nullable org.bukkit.entity.ProjectileGets the projectile.@Nullable org.bukkit.entity.LivingEntityGets the target entity.@NotNull org.bukkit.inventory.ItemStackGets the weapon item.booleanisBow()Checks if this is a bow event.booleanChecks if this is a critical hit.booleanChecks if this is a crossbow event.booleanChecks if this is a shooting event.booleanChecks if this is a throwing event.booleanChecks if this is a trident event.voidsetCritical(boolean critical) Sets whether this is a critical hit.voidsetForce(float force) Sets the force of the shot.voidsetPierceLevel(int pierceLevel) Sets the pierce level.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
-
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 newWeaponEvent.- Parameters:
enchantment- the enchantment that triggered this eventlevel- the level of the enchantmentscaledValue- the scaled value from the enchantment's scaling algorithmplayer- the player using the weaponweapon- the weapon itemlocation- the location of the eventtarget- the target entity, or nullprojectile- the projectile, or nullisBow- true if this is a bow eventisCrossbow- true if this is a crossbow eventisTrident- true if this is a trident eventisShooting- true if shootingisThrowing- true if throwingforce- the force of the shot (0.0-1.0)critical- true if critical hitpierceLevel- 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:
getHandlersin classEnchantEffectEvent
-
getHandlerList
@NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()Gets the handler list for this event type.- Returns:
- the handler list
-