Class VeinMinerToolCategory

java.lang.Object
wtf.choco.veinminer.tool.VeinMinerToolCategory
All Implemented Interfaces:
Comparable<VeinMinerToolCategory>
Direct Known Subclasses:
VeinMinerToolCategoryHand

public class VeinMinerToolCategory extends Object implements Comparable<VeinMinerToolCategory>
Represents a category of tools.
  • Constructor Details

    • VeinMinerToolCategory

      public VeinMinerToolCategory(@NotNull @NotNull String id, int priority, @Nullable @Nullable String nbtValue, @NotNull @NotNull BlockList blockList, @NotNull @NotNull VeinMiningConfig config, @NotNull @NotNull Set<ItemType> items)
      Construct a new VeinMinerToolCategory.
      Parameters:
      id - the unique id of the tool category
      priority - the category's priority
      nbtValue - the required value of the NBT key
      blockList - the category block list
      config - the category config
      items - the items in this category
  • Method Details

    • getId

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

      public int getPriority()
      Get the priority of this tool category.

      Priority determines whether or not one category will be selected over another under the circumstance that more than one category matches any given item type. For instance, if two categories declare that a diamond_pickaxe is on the list of items, the category with the higher priority should be selected for use. Higher integers are more important than categories with lower integers. Categories with the same priority will not abide by any defined behaviour.

      Returns:
      the priority
    • getNBTValue

      @Nullable public @Nullable String getNBTValue()
      Get the value that must be on items in this category to be vein mineable.

      Callers of containsItem(ItemType) should verify also that any ItemStack to be checked contains also the value returned by this method.

      Returns:
      the NBT value, or null if no NBT is required
    • getBlockList

      @NotNull public @NotNull BlockList getBlockList()
      Get the BlockList for this tool category.
      Returns:
      the block list
    • getConfig

      @NotNull public @NotNull VeinMiningConfig getConfig()
      Get the VeinMiningConfig for this tool category.
      Returns:
      the config
    • addItem

      public boolean addItem(@NotNull @NotNull ItemType itemType)
      Add an item to this category.
      Parameters:
      itemType - the item type to add
      Returns:
      true if the item list was modified, false if the item was already added
    • removeItem

      public boolean removeItem(@NotNull @NotNull ItemType itemType)
      Remove an item from this category.
      Parameters:
      itemType - the item type to remove
      Returns:
      true if the item list was modified, false if the item had not been added
    • containsItem

      public boolean containsItem(@NotNull @NotNull ItemType item)
      Check whether or not this category contains the given item.
      Parameters:
      item - the item to check
      Returns:
      true if this category contains the item, false otherwise
      API Note:
      this method only verifies that the type is contained in this category, not whether or not an item stack contains the required NBT. For this, callers should also check that the value of getNBTValue() is present in addition to the result of this method.
    • getItems

      @NotNull public @NotNull @UnmodifiableView Set<ItemType> getItems()
      Get an unmodifiable collection of all items in this category.
      Returns:
      the items
    • compareTo

      public int compareTo(VeinMinerToolCategory other)

      Default behaviour is to compare against a category's priority (getPriority()).

      Specified by:
      compareTo in interface Comparable<VeinMinerToolCategory>
    • hashCode

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

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

      public String toString()
      Overrides:
      toString in class Object