Class ToolCategory

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

public class ToolCategory
extends Object
Represents a category of tools recognized by VeinMiner. Categories may possess their own AlgorithmConfig, BlockList and set of ToolTemplates which further specifies its criteria when players vein mine.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static ToolCategory HAND  
  • Constructor Summary

    Constructors 
    Constructor Description
    ToolCategory​(@NotNull String id, @NotNull AlgorithmConfig configuration)
    Construct a new tool category with an empty block list.
    ToolCategory​(@NotNull String id, @NotNull AlgorithmConfig configuration, @NotNull ToolTemplate... tools)
    Construct a new tool category with an empty block list.
    ToolCategory​(@NotNull String id, @NotNull BlockList blocklist, @NotNull AlgorithmConfig configuration)
    Construct a new tool category with an empty block and tool list.
    ToolCategory​(@NotNull String id, @NotNull BlockList blocklist, @NotNull AlgorithmConfig configuration, @NotNull ToolTemplate... tools)
    Construct a new tool category.
  • Method Summary

    Modifier and Type Method Description
    void addTool​(@NotNull ToolTemplate template)
    Add a tool template to this tool category
    static void clearCategories()
    Clear all registered categories.
    void clearTools()
    Clear all tool templates from this category.
    boolean containsTool​(@NotNull org.bukkit.inventory.ItemStack item)
    Check whether or not the provided item is a part of this category.
    boolean containsTool​(@NotNull org.bukkit.Material material)
    Check whether or not the provided material is a part of this category.
    boolean equals​(Object obj)  
    static @Nullable ToolCategory get​(@NotNull String id)
    Get a tool category based on its (case-insensitive) id.
    static @Nullable ToolCategory get​(@Nullable org.bukkit.inventory.ItemStack item)
    Get a tool category based on the provided tool.
    static @NotNull Collection<ToolCategory> getAll()
    Get an immutable collection of all registered tool categories.
    @NotNull BlockList getBlocklist()
    Get the blocklist for this category.
    @NotNull AlgorithmConfig getConfig()
    Get the algorithm config for this tool category.
    @NotNull String getId()
    Get the unique id of this tool category.
    static int getRegisteredAmount()
    Get the amount of tool categories registered.
    @NotNull List<ToolTemplate> getTools()
    Get a list of all tool templates that apply to this category.
    static @NotNull Pair<ToolCategory,​ToolTemplate> getWithTemplate​(@Nullable org.bukkit.inventory.ItemStack item)
    Get a tool category based on the provided tool as well as the template against which the tool was matched.
    int hashCode()  
    static void register​(@NotNull ToolCategory category)
    Register a tool category.
    boolean removeTool​(@NotNull org.bukkit.inventory.ItemStack item)
    Remove all tool templates from this tool category that match the provided item.
    boolean removeTool​(@NotNull org.bukkit.Material material)
    Remove all tool templates from this tool category that match the provided material.
    boolean removeTool​(@NotNull ToolTemplate template)
    Remove a tool template from this tool category

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ToolCategory

      public ToolCategory​(@NotNull @NotNull String id, @NotNull @NotNull BlockList blocklist, @NotNull @NotNull AlgorithmConfig configuration)
      Construct a new tool category with an empty block and tool list.
      Parameters:
      id - the unique id of the tool category. Recommended to be a single-worded, PascalCase id. Must match [A-Za-z0-9]
      blocklist - the category block list
      configuration - the algorithm configuration for this category
    • ToolCategory

      public ToolCategory​(@NotNull @NotNull String id, @NotNull @NotNull BlockList blocklist, @NotNull @NotNull AlgorithmConfig configuration, @NotNull @NotNull ToolTemplate... tools)
      Construct a new tool category.
      Parameters:
      id - the unique id of the tool category. Recommended to be a single-worded, PascalCase id. Must match [A-Za-z0-9]
      blocklist - the category block list
      tools - the tools that apply to this category
      configuration - the algorithm configuration for this category
    • ToolCategory

      public ToolCategory​(@NotNull @NotNull String id, @NotNull @NotNull AlgorithmConfig configuration, @NotNull @NotNull ToolTemplate... tools)
      Construct a new tool category with an empty block list.
      Parameters:
      id - the unique id of the tool category. Recommended to be a single-worded, PascalCase id. Must match [A-Za-z0-9]
      tools - the tools that apply to this category
      configuration - the algorithm configuration for this category
    • ToolCategory

      public ToolCategory​(@NotNull @NotNull String id, @NotNull @NotNull AlgorithmConfig configuration)
      Construct a new tool category with an empty block list.
      Parameters:
      id - the unique id of the tool category. Recommended to be a single-worded, PascalCase id. Must match [A-Za-z0-9]
      configuration - the algorithm configuration for this category
  • Method Details

    • getId

      @NotNull public @NotNull String getId()
      Get the unique id of this tool category.
      Returns:
      this category's id
    • getConfig

      @NotNull public @NotNull AlgorithmConfig getConfig()
      Get the algorithm config for this tool category. This category should have precedence over the global algorithm config.
      Returns:
      the algorithm config
    • addTool

      public void addTool​(@NotNull @NotNull ToolTemplate template)
      Add a tool template to this tool category
      Parameters:
      template - the template to add
    • removeTool

      public boolean removeTool​(@NotNull @NotNull ToolTemplate template)
      Remove a tool template from this tool category
      Parameters:
      template - the template to remove
      Returns:
      true if removed, false otherwise
    • removeTool

      public boolean removeTool​(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Remove all tool templates from this tool category that match the provided item.
      Parameters:
      item - the item to remove
      Returns:
      true if removed, false otherwise
    • removeTool

      public boolean removeTool​(@NotNull @NotNull org.bukkit.Material material)
      Remove all tool templates from this tool category that match the provided material. This will not remove any templates that have specific meta such as a name or lore, only material templates (i.e. a regular diamond pickaxe or stone axe).
      Parameters:
      material - the material to remove
      Returns:
      true if removed, false otherwise
    • containsTool

      public boolean containsTool​(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Check whether or not the provided item is a part of this category. The item's name and lore will be taken into consideration.
      Parameters:
      item - the item to check
      Returns:
      true if contained, false otherwise
    • containsTool

      public boolean containsTool​(@NotNull @NotNull org.bukkit.Material material)
      Check whether or not the provided material is a part of this category.
      Parameters:
      material - the material to check
      Returns:
      true if contained, false otherwise
    • getTools

      @NotNull public @NotNull List<ToolTemplate> getTools()
      Get a list of all tool templates that apply to this category. Any changes made to the returned collection will not reflect upon the category.
      Returns:
      the tool templates
    • clearTools

      public void clearTools()
      Clear all tool templates from this category.
    • getBlocklist

      @NotNull public @NotNull BlockList getBlocklist()
      Get the blocklist for this category.
      Returns:
      the blocklist
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object
    • get

      @Nullable public static @Nullable ToolCategory get​(@NotNull @NotNull String id)
      Get a tool category based on its (case-insensitive) id.
      Parameters:
      id - the id of the category to get
      Returns:
      the tool category. null if none
    • get

      @Nullable public static @Nullable ToolCategory get​(@Nullable @Nullable org.bukkit.inventory.ItemStack item)
      Get a tool category based on the provided tool. If the tool applies to a category, it will be returned. If more than one category includes this tool, the category that was registered first will be returned.
      Parameters:
      item - the item whose category to get
      Returns:
      the tool category. null if none
    • register

      public static void register​(@NotNull @NotNull ToolCategory category)
      Register a tool category.
      Parameters:
      category - the category to register
    • getWithTemplate

      @NotNull public static @NotNull Pair<ToolCategory,​ToolTemplate> getWithTemplate​(@Nullable @Nullable org.bukkit.inventory.ItemStack item)
      Get a tool category based on the provided tool as well as the template against which the tool was matched. If the tool applies to a category, it will be returned. If more than one category includes this tool, the category that was registered first will be returned.
      Parameters:
      item - the item whose category to get
      Returns:
      the tool category and matched template. null if none
    • getRegisteredAmount

      public static int getRegisteredAmount()
      Get the amount of tool categories registered.
      Returns:
      the amount of registered categories
    • getAll

      @NotNull public static @NotNull Collection<ToolCategory> getAll()
      Get an immutable collection of all registered tool categories.
      Returns:
      all tool categories
    • clearCategories

      public static void clearCategories()
      Clear all registered categories.