Package wtf.choco.veinminer.tool
Class ToolCategoryRegistry
java.lang.Object
wtf.choco.veinminer.tool.ToolCategoryRegistry
A registry to which
VeinMinerToolCategories
may be registered.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@Nullable VeinMinerToolCategory
Get theVeinMinerToolCategory
with the given id.@Nullable VeinMinerToolCategory
Get theVeinMinerToolCategory
that contains the givenItemType
.@Nullable VeinMinerToolCategory
get
(@NotNull ItemType itemType, @NotNull Predicate<VeinMinerToolCategory> categoryPredicate) @NotNull @UnmodifiableView Collection<? extends VeinMinerToolCategory>
getAll()
Get all registeredVeinMinerToolCategories
.void
register
(@NotNull VeinMinerToolCategory category) Register the givenVeinMinerToolCategory
.int
size()
Get the amount of registered tool categories.@Nullable VeinMinerToolCategory
unregister
(@NotNull String id) Unregister theVeinMinerToolCategory
with the given id.boolean
unregister
(@NotNull VeinMinerToolCategory category) Unregister the givenVeinMinerToolCategory
.void
Unregister all tool categories.
-
Constructor Details
-
ToolCategoryRegistry
public ToolCategoryRegistry()
-
-
Method Details
-
register
Register the givenVeinMinerToolCategory
.- Parameters:
category
- the category to register
-
get
Get theVeinMinerToolCategory
with the given id.- Parameters:
id
- the id of the category to get- Returns:
- the category, or null if none exists
-
get
@Nullable public @Nullable VeinMinerToolCategory get(@NotNull @NotNull ItemType itemType, @NotNull @NotNull Predicate<VeinMinerToolCategory> categoryPredicate) Get theVeinMinerToolCategory
that contains the givenItemType
and matches the givenPredicate
. There is no guarantee as to which category will be returned if more than one category contains the provided ItemType.- Parameters:
itemType
- the item typecategoryPredicate
- a predicate to apply on top of the item condition. If the predicate returns false for any given category, it will not be returned by this method. Useful for an additional permission check on a category- Returns:
- the corresponding tool category, or null if no category contains the item
-
get
Get theVeinMinerToolCategory
that contains the givenItemType
. There is no guarantee as to which category will be returned if more than one category contains the provided ItemType.- Parameters:
itemType
- the item type- Returns:
- the corresponding tool category, or null if no category contains the item
-
unregister
Unregister the givenVeinMinerToolCategory
.- Parameters:
category
- the category to unregister- Returns:
- true if unregistered, false if the category was not registered
-
unregister
Unregister theVeinMinerToolCategory
with the given id.- Parameters:
id
- the id of the category- Returns:
- the category that was unregistered, or null if not registered
-
size
public int size()Get the amount of registered tool categories.- Returns:
- size of this registry
-
getAll
Get all registeredVeinMinerToolCategories
.- Returns:
- all categories
-
unregisterAll
public void unregisterAll()Unregister all tool categories.
-