Package wtf.choco.locksecurity.api.key
Interface IKeyFactory<T extends IKeyBuilder>
- Type Parameters:
T
- theIKeyBuilder
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 anIKeyBuilder
instance to build a new keyItemStack
.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 ofILockedBlocks
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 suppliedItemStack
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 anIKeyBuilder
instance to modify an existing keyItemStack
.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 suppliedItemStack
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
Get anIKeyBuilder
instance to build a new keyItemStack
.- Returns:
- a key builder
-
modify
Get anIKeyBuilder
instance to modify an existing keyItemStack
.- 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 resultantItemStack
will:- Unlock the blocks from either key
- Have the merged flags from each key
- Parameters:
firstKey
- the first smithed key. Must not be nullsecondKey
- the second smithed key. Must not be nullamount
- 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 resultantItemStack
will:- Unlock the blocks from either key
- Have the merged flags from each key
- Parameters:
firstKey
- the first smithed key. Must not be nullsecondKey
- the second smithed key. Must not be null- Returns:
- the merged key
- See Also:
merge(ItemStack, ItemStack, int)
-
getUnlocks
Get an array ofILockedBlocks
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, seemodify(ItemStack)
.- Parameters:
item
- the item whose blocks to get. Must not be null- Returns:
- the locked blocks
-
hasFlag
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)
andSet.contains(Object)
on the result as this method will fetch flags for each call.- Parameters:
item
- the item to check. Must not be nullflag
- the flag for which to check.- Returns:
- true if the item contains the flag, false otherwise or if is not a key
-
getFlags
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. theILockedBlockManager
for locked blocks).- Parameters:
key
- the key to refresh. Must not be null- Returns:
- the refreshed key
-