Class ArrowRegistry

java.lang.Object
wtf.choco.arrows.registry.ArrowRegistry
All Implemented Interfaces:
Iterable<AlchemicalArrow>

public final class ArrowRegistry
extends Object
implements Iterable<AlchemicalArrow>
Handles the registration of AlchemicalArrow implementations.
Author:
Parker Hawke - Choco
  • Field Details

    • BOW_MATERIALS

      public static final Set<org.bukkit.Material> BOW_MATERIALS
  • Constructor Details

    • ArrowRegistry

      public ArrowRegistry()
  • Method Details

    • register

      public void register​(@NotNull @NotNull AlchemicalArrow arrow)
      Register a custom AlchemicalArrow implementation. All arrows must be registered here in order to be recognised by AlchemicalArrows when shooting custom arrows. The provided instance must have a unique, non-null key (AlchemicalArrow.getKey()), as well as a unique, non-null ItemStack of type Material.ARROW.
      Parameters:
      arrow - the arrow implementation to register
      Throws:
      IllegalArgumentException - if arrow, its key or its ItemStack is null, or if the ItemStack is not of type Material.ARROW
      IllegalStateException - if an arrow with the ID has already been registered, or an arrow with the ItemStack has already been registered
    • unregister

      public void unregister​(@NotNull @NotNull AlchemicalArrow arrow)
      Unregister an AlchemicalArrow implementation from the arrow registry. Note that upon unregistration, the arrow will no longer be recognised when attempting to shoot one.
      Parameters:
      arrow - the arrow to unregister
    • unregister

      public void unregister​(@NotNull @NotNull Class<? extends AlchemicalArrow> arrowClass)
      Unregister an AlchemicalArrow implementation from the arrow registry based upon its class. Note that upon unregistration, the arrow will no longer be recognised when attempting to shoot one.
      Parameters:
      arrowClass - the class of the arrow to unregister
    • get

      @Nullable public <T extends AlchemicalArrow> T get​(@NotNull @NotNull Class<T> clazz)
      Get the registered instance of the provided AlchemicalArrow class. The registration instance provides various informational methods such as its representing ItemStack as well as a method to construct a new instance of the AlchemicalArrowEntity such that an instance of Arrow is provided.
      Type Parameters:
      T - the alchemical arrow class type
      Parameters:
      clazz - the class of the AlchemicalArrow whose registration to get
      Returns:
      the registered AlchemicalArrow. null if none
    • get

      @Nullable public @Nullable AlchemicalArrow get​(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Get the registered instance of an AlchemicalArrow represented by the provided ItemStack. The registration instance provides various informational methods such as its representing ItemStack as well as a method to construct a new instance of the AlchemicalArrowEntity such that an instance of Arrow is provided.
      Parameters:
      item - the item of the AlchemicalArrow instance to retrieve
      Returns:
      the registered AlchemicalArrow represented by the provided ItemStack. null if none
    • get

      @Nullable public @Nullable AlchemicalArrow get​(@NotNull @NotNull org.bukkit.NamespacedKey key)
      Get the registered instance of an AlchemicalArrow according to its unique namespaced key. The registration instance provides various informational methods such as its representing ItemStack as well as a method to construct a new instance of the AlchemicalArrowEntity such that an instance of Arrow is provided.
      Parameters:
      key - the unique key of the AlchemicalArrow instance to retrieve
      Returns:
      the registered AlchemicalArrow represented by the provided ItemStack. null if none
    • get

      @Nullable public @Nullable AlchemicalArrow get​(@NotNull @NotNull String key)
      Get the registered instance of an AlchemicalArrow according to its registered id. The registration instance provides various informational methods such as its representing ItemStack as well as a method to construct a new instance of the AlchemicalArrowEntity such that an instance of Arrow is provided.
      Parameters:
      key - the registered NamespacedKey of the AlchemicalArrow instance to retrieve
      Returns:
      the registered AlchemicalArrow represented by the provided key. null if none
    • getRegisteredArrows

      @NotNull public @NotNull Collection<AlchemicalArrow> getRegisteredArrows()
      Get the registry for all instances of AlchemicalArrows.
      Returns:
      the arrow registration data
    • clear

      public void clear()
      Clear all registry data. This will remove all data previously registered by AlchemicalArrows and by plugins that have registered their own arrows.
    • iterator

      public Iterator<AlchemicalArrow> iterator()
      Specified by:
      iterator in interface Iterable<AlchemicalArrow>