Class AlchemicalArrow

java.lang.Object
wtf.choco.arrows.api.AlchemicalArrow
Direct Known Subclasses:
ConfigurableAlchemicalArrow

public abstract class AlchemicalArrow
extends Object
Represents the base of an alchemical arrow with special effects upon hitting a block, entity or player
Author:
Parker Hawke - Choco
  • Constructor Details

    • AlchemicalArrow

      public AlchemicalArrow()
  • Method Details

    • getKey

      @NotNull public abstract @NotNull org.bukkit.NamespacedKey getKey()
      Get this arrow's unique key.
      Returns:
      the unique key
    • getDisplayName

      @NotNull public abstract @NotNull String getDisplayName()
      Get the display name of this alchemical arrow. This includes colour codes and formatting. The returned String should be expected in messages sent to players
      Returns:
      the arrow's display name
    • getItem

      @NotNull public abstract @NotNull org.bukkit.inventory.ItemStack getItem()
      Get the item representation of this alchemical arrow. The type must be be tagged by Tag.ITEMS_ARROWS, otherwise an exception will be thrown at registration.

      NOTE: This item does NOT have applied the NamespacedKey for this arrow and cannot be shot unless matchesItem(ItemStack) is overridden by implementation. Callers should prefer instead to call createItemStack(). This method is expected to be overridden by implementations, NOT to be called by API.

      Returns:
      the arrow item
    • createItemStack

      public org.bukkit.inventory.ItemStack createItemStack()
      Create a new ItemStack that represents this AlchemicalArrow in an inventory. This arrow can be shot by a player.
      Returns:
      the item stack
    • createItemStack

      public final org.bukkit.inventory.ItemStack createItemStack​(int amount)
      Create a new ItemStack that represents this AlchemicalArrow in an inventory. This arrow can be shot by a player.
      Parameters:
      amount - the item amount
      Returns:
      the item stack
    • matchesItem

      public boolean matchesItem​(org.bukkit.inventory.ItemStack item)
      Check whether or not the provided ItemStack represents this AlchemicalArrow.
      Parameters:
      item - the item to check
      Returns:
      true if valid, false otherwise
    • getProperties

      @NotNull public final @NotNull PropertyMap getProperties()
      Get a map containing all properties for this arrow
      Returns:
      the arrow properties
    • tick

      public void tick​(@NotNull @NotNull AlchemicalArrowEntity arrow, @NotNull @NotNull org.bukkit.Location location)
      Called 20 times every second. This method is intended for displaying particles around the arrow, performing tasks whilst the arrow is still in the world, etc.
      Parameters:
      arrow - the alchemical arrow entity instance
      location - the arrow's current location at this tick
    • onHitBlock

      public void onHitBlock​(@NotNull @NotNull AlchemicalArrowEntity arrow, @NotNull @NotNull org.bukkit.block.Block block)
      Called when the arrow hits a solid block
      Parameters:
      arrow - the alchemical arrow entity instance
      block - the block on which the arrow landed
    • onHitPlayer

      public void onHitPlayer​(@NotNull @NotNull AlchemicalArrowEntity arrow, @NotNull @NotNull org.bukkit.entity.Player player)
      Called when the arrow hits a player
      Parameters:
      arrow - the alchemical arrow entity instance
      player - the player damaged by the arrow
    • onHitEntity

      public void onHitEntity​(@NotNull @NotNull AlchemicalArrowEntity arrow, @NotNull @NotNull org.bukkit.entity.Entity entity)
      Called when the arrow hits an entity (this excludes Players. For Players, see onHitPlayer(AlchemicalArrowEntity, Player))
      Parameters:
      arrow - the alchemical arrow entity instance
      entity - the entity damaged by the arrow
    • onShootFromPlayer

      public boolean onShootFromPlayer​(@NotNull @NotNull AlchemicalArrowEntity arrow, @NotNull @NotNull org.bukkit.entity.Player player)
      Called at low priority when a player has successfully shot this alchemical arrow, but it has yet to be registered. Such that this method returns true, the alchemical arrow will be launched
      Parameters:
      arrow - the alchemical arrow entity instance
      player - the player that shot the arrow
      Returns:
      whether the shot should be permitted or not
    • onShootFromSkeleton

      public boolean onShootFromSkeleton​(@NotNull @NotNull AlchemicalArrowEntity arrow, @NotNull @NotNull org.bukkit.entity.Skeleton skeleton)
      Called at a low priority when a Skeleton successfully shoots an arrow, but it has yet to be registered. Such that this method returns true, the alchemical arrow will be launched. The ArrowProperty.SKELETONS_CAN_SHOOT property must return true in order for this method to be invoked
      Parameters:
      arrow - the alchemical arrow entity instance
      skeleton - the skeleton that shot the arrow
      Returns:
      whether the shot should be permitted or not
    • onShootFromBlockSource

      public boolean onShootFromBlockSource​(@NotNull @NotNull AlchemicalArrowEntity arrow, @NotNull @NotNull org.bukkit.projectiles.BlockProjectileSource source)
      Called at a low priority when a BlockProjectileSource (i.e. Dispenser) shoots an arrow, but it has yet to be registered. Such that this method returns true, the alchemical arrow will be launched
      Parameters:
      arrow - the alchemical arrow entity instance
      source - the block source that shot the arrow
      Returns:
      whether the shot should be permitted or not
    • hitEntityEventHandler

      public void hitEntityEventHandler​(@NotNull @NotNull AlchemicalArrowEntity arrow, @NotNull @NotNull org.bukkit.event.entity.EntityDamageByEntityEvent event)
      Called the instant before onHitPlayer(AlchemicalArrowEntity, Player) or onHitEntity(AlchemicalArrowEntity, Entity) is called. Used to cancel events if necessary
      Parameters:
      arrow - the alchemical arrow entity instance
      event - the EntityDamageByEntityEvent source
    • hitGroundEventHandler

      public void hitGroundEventHandler​(@NotNull @NotNull AlchemicalArrowEntity arrow, @NotNull @NotNull org.bukkit.event.entity.ProjectileHitEvent event)
      Called the instant before onHitBlock(AlchemicalArrowEntity, Block) is called. Used to cancel events if necessary
      Parameters:
      arrow - the alchemical arrow entity instance
      event - the ProjectileHitEvent source
    • shootEventHandler

      public void shootEventHandler​(@NotNull @NotNull AlchemicalArrowEntity arrow, @NotNull @NotNull org.bukkit.event.entity.ProjectileLaunchEvent event)
      Parameters:
      arrow - the alchemical arrow entity instance
      event - the ProjectileLaunchEvent source
    • createNewArrow

      @NotNull public @NotNull AlchemicalArrowEntity createNewArrow​(@NotNull @NotNull org.bukkit.entity.Arrow arrow)
      Create a new instance of an AlchemicalArrowEntity. If a custom AlchemicalArrowEntity implementation is used, this method must be overridden to return a custom instance of it. Under no circumstance should additional, non-arrow entity-related code be executed in an overridden implementation of this method. For additional logic, see AlchemicalArrow's various methods and override them where required
      Parameters:
      arrow - the Bukkit Arrow instance from which to create an AlchemicalArrowEntity
      Returns:
      the new AlchemicalArrowEntity instance of this implementation
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals​(Object object)
      Overrides:
      equals in class Object