Class ToolCategoryRegistry

java.lang.Object
wtf.choco.veinminer.tool.ToolCategoryRegistry

public final class ToolCategoryRegistry extends Object
A registry to which VeinMinerToolCategories may be registered.
  • Constructor Details

    • ToolCategoryRegistry

      public ToolCategoryRegistry()
  • Method Details

    • register

      public void register(@NotNull @NotNull VeinMinerToolCategory category)
      Register the given VeinMinerToolCategory.
      Parameters:
      category - the category to register
    • get

      @Nullable public @Nullable VeinMinerToolCategory get(@NotNull @NotNull String id)
      Get the VeinMinerToolCategory 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 the VeinMinerToolCategory that contains the given ItemType and matches the given Predicate. 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
      categoryPredicate - 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

      @Nullable public @Nullable VeinMinerToolCategory get(@NotNull @NotNull ItemType itemType)
      Get the VeinMinerToolCategory that contains the given ItemType. 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

      public boolean unregister(@NotNull @NotNull VeinMinerToolCategory category)
      Unregister the given VeinMinerToolCategory.
      Parameters:
      category - the category to unregister
      Returns:
      true if unregistered, false if the category was not registered
    • unregister

      @Nullable public @Nullable VeinMinerToolCategory unregister(@NotNull @NotNull String id)
      Unregister the VeinMinerToolCategory 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

      @NotNull public @NotNull @UnmodifiableView Collection<? extends VeinMinerToolCategory> getAll()
      Get all registered VeinMinerToolCategories.
      Returns:
      all categories
    • unregisterAll

      public void unregisterAll()
      Unregister all tool categories.