Interface IKeyFactory<T extends IKeyBuilder>

Type Parameters:
T - the IKeyBuilder type supplied by this factory

public interface IKeyFactory<T extends IKeyBuilder>
A factory class used to create ItemStacks used to lock or open blocks.
Since:
3.0.0
Author:
Parker Hawke - Choco
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static IKeyFactory<IKeyBuilderSmithed> SMITHED
    The smithed key factory.
    static IKeyFactory<IKeyBuilderUnsmithed> UNSMITHED
    The unsmithed key factory.
  • Method Summary

    Modifier and Type Method Description
    T builder()
    Get an IKeyBuilder instance to build a new key ItemStack.
    Set<KeyFlag> getFlags​(org.bukkit.inventory.ItemStack item)
    Get an immutable Set of all flags present on the supplied key.
    ILockedBlock[] getUnlocks​(org.bukkit.inventory.ItemStack item)
    Get an array of ILockedBlocks that the provided key unlocks.
    boolean hasFlag​(org.bukkit.inventory.ItemStack item, KeyFlag flag)
    Check whether or not the supplied key has the specified flag.
    boolean isKey​(org.bukkit.inventory.ItemStack item)
    Check whether or not the supplied ItemStack is a valid key for this factory.
    org.bukkit.inventory.ItemStack merge​(org.bukkit.inventory.ItemStack firstKey, org.bukkit.inventory.ItemStack secondKey)
    Merge two smithed keys into one.
    org.bukkit.inventory.ItemStack merge​(org.bukkit.inventory.ItemStack firstKey, org.bukkit.inventory.ItemStack secondKey, int amount)
    Merge two smithed keys into one.
    T modify​(org.bukkit.inventory.ItemStack item)
    Get an IKeyBuilder instance to modify an existing key ItemStack.
    org.bukkit.inventory.ItemStack refresh​(org.bukkit.inventory.ItemStack key)
    Refresh the supplied key.
  • Field Details

  • Method Details

    • isKey

      boolean isKey​(@Nullable org.bukkit.inventory.ItemStack item)
      Check whether or not the supplied ItemStack is a valid key for this factory.
      Parameters:
      item - the item to check
      Returns:
      true if the key is producable using this factory, false otherwise or if null
    • builder

      @NotNull T builder()
      Get an IKeyBuilder instance to build a new key ItemStack.
      Returns:
      a key builder
    • modify

      @NotNull T modify​(@NotNull org.bukkit.inventory.ItemStack item)
      Get an IKeyBuilder instance to modify an existing key ItemStack.
      Parameters:
      item - the key to modify. Must not be null
      Returns:
      a key builder with pre-defined values
    • merge

      @NotNull org.bukkit.inventory.ItemStack merge​(@NotNull org.bukkit.inventory.ItemStack firstKey, @NotNull org.bukkit.inventory.ItemStack secondKey, int amount)
      Merge two smithed keys into one. The resultant ItemStack will:
      • Unlock the blocks from either key
      • Have the merged flags from each key
      Parameters:
      firstKey - the first smithed key. Must not be null
      secondKey - the second smithed key. Must not be null
      amount - the amount of keys to create
      Returns:
      the merged key
    • merge

      @NotNull org.bukkit.inventory.ItemStack merge​(@NotNull org.bukkit.inventory.ItemStack firstKey, @NotNull org.bukkit.inventory.ItemStack secondKey)
      Merge two smithed keys into one. The resultant ItemStack will:
      • Unlock the blocks from either key
      • Have the merged flags from each key
      Parameters:
      firstKey - the first smithed key. Must not be null
      secondKey - the second smithed key. Must not be null
      Returns:
      the merged key
      See Also:
      merge(ItemStack, ItemStack, int)
    • getUnlocks

      @NotNull ILockedBlock[] getUnlocks​(@NotNull org.bukkit.inventory.ItemStack item)
      Get an array of ILockedBlocks that the provided key unlocks. Changes made to the returned array will not be reflected on the key. In order to change the blocks a key may lock, see modify(ItemStack).
      Parameters:
      item - the item whose blocks to get. Must not be null
      Returns:
      the locked blocks
    • hasFlag

      boolean hasFlag​(@NotNull org.bukkit.inventory.ItemStack item, @NotNull KeyFlag flag)
      Check whether or not the supplied key has the specified flag.

      If more than one call to this method is being made, it is recommended instead to use getFlags(ItemStack) and Set.contains(Object) on the result as this method will fetch flags for each call.

      Parameters:
      item - the item to check. Must not be null
      flag - the flag for which to check.
      Returns:
      true if the item contains the flag, false otherwise or if is not a key
    • getFlags

      @NotNull Set<KeyFlag> getFlags​(@NotNull org.bukkit.inventory.ItemStack item)
      Get an immutable Set of all flags present on the supplied key.
      Parameters:
      item - the item whose flags to get. Must not be null
      Returns:
      the key flags
    • refresh

      @NotNull org.bukkit.inventory.ItemStack refresh​(@NotNull org.bukkit.inventory.ItemStack key)
      Refresh the supplied key. A refreshed key will have its lore and name updated according to data fetched from other sources (i.e. the ILockedBlockManager for locked blocks).
      Parameters:
      key - the key to refresh. Must not be null
      Returns:
      the refreshed key