Interface VeinBlock

All Superinterfaces:
Comparable<VeinBlock>

public interface VeinBlock
extends Comparable<VeinBlock>
Represents a block that may be vein mined. These blocks may or may not contain additional data or wildcards, therefore the result of encapsulates(Material) (and its overrides) may vary based on the implementation and whether or not the block has additional data (see hasSpecificData()).
Author:
Parker Hawke - 2008Choco
  • Method Summary

    Modifier and Type Method Description
    @NotNull String asDataString()
    Get this VeinBlock instance as a readable data String.
    static void clearCache()
    Clear the VeinBlock cache.
    default int compareTo​(@Nullable VeinBlock other)  
    boolean encapsulates​(@NotNull org.bukkit.block.Block block)
    Check whether or not the provided block is encapsulated by this VeinBlock.
    boolean encapsulates​(@NotNull org.bukkit.block.data.BlockData data)
    Check whether or not the provided data is encapsulated by this VeinBlock.
    boolean encapsulates​(@NotNull org.bukkit.Material material)
    Check whether or not the provided material is encapsulated by this VeinBlock.
    static @Nullable VeinBlock fromString​(@NotNull String value)
    Get a VeinBlock based on a String representation of its material and/or state.
    static @NotNull VeinBlock get​(@NotNull org.bukkit.block.data.BlockData data)
    Get a VeinBlock based on block data with a set of states.
    static @NotNull VeinBlock get​(@NotNull org.bukkit.Material material)
    Get a VeinBlock based on type with no additional block states.
    @NotNull org.bukkit.block.data.BlockData getBlockData()
    Get the Bukkit BlockData represented by this block.
    @NotNull org.bukkit.Material getType()
    Get the Bukkit Material represented by this block
    boolean hasSpecificData()
    Check whether or not this block includes more specific block data (for example, "minecraft:chest" would return false whereas "minecraft:chest[facing=north]" would return true due to the specified "facing" block state.
  • Method Details

    • getType

      @NotNull @NotNull org.bukkit.Material getType()
      Get the Bukkit Material represented by this block
      Returns:
      the material type
    • hasSpecificData

      boolean hasSpecificData()
      Check whether or not this block includes more specific block data (for example, "minecraft:chest" would return false whereas "minecraft:chest[facing=north]" would return true due to the specified "facing" block state.
      Returns:
      true if specific data is defined, false if wildcarded to type only
    • getBlockData

      @NotNull @NotNull org.bukkit.block.data.BlockData getBlockData()
      Get the Bukkit BlockData represented by this block. If this VeinBlock has no specific data, this method will return the equivalent of Material.createBlockData() with no additional block state data.
      Returns:
      the block data
    • encapsulates

      boolean encapsulates​(@NotNull @NotNull org.bukkit.block.Block block)
      Check whether or not the provided block is encapsulated by this VeinBlock. If encapsulated, the provided block may be considered valid to vein mine.

      The result of this method may vary based on whether or not this block has specific data. If specific data is defined, any non-specified states in the underlying BlockData will be ignored... only specified states will be compared. If otherwise, only the block's type will be compared.

      Parameters:
      block - the block to check
      Returns:
      true if encapsulated and valid to vein mine for this type, false otherwise
      See Also:
      encapsulates(BlockData), encapsulates(Material)
    • encapsulates

      boolean encapsulates​(@NotNull @NotNull org.bukkit.block.data.BlockData data)
      Check whether or not the provided data is encapsulated by this VeinBlock. If encapsulated, the provided data may be considered valid to vein mine.

      The result of this method may vary based on whether or not this block has specific data. If specific data is defined, any non-specified states in the underlying BlockData will be ignored... only specified states will be compared. If otherwise, only the data's type will be compared.

      Parameters:
      data - the data to check
      Returns:
      true if encapsulated and valid to vein mine for this type, false otherwise
      See Also:
      encapsulates(Block), encapsulates(Material)
    • encapsulates

      boolean encapsulates​(@NotNull @NotNull org.bukkit.Material material)
      Check whether or not the provided material is encapsulated by this VeinBlock. If encapsulated, the provided material may be considered valid to vein mine.

      The result of this method will vary based on whether or not this block has specific data. If specific data is defined, this method will always return false... because materials are stateless, they cannot possible match a vein block with specified data. That being said, while this method may return false for identical materials, getType() when compared to the provided material will return true as expected. In other words,

      veinblock.getType() == material will return true.
      veinblock.encapsulates(material) will return false.

      If otherwise, disregard the above, the block's type will be compared as expected.

      Parameters:
      material - the material to check
      Returns:
      true if encapsulated and valid to vein mine for this type, false otherwise
      See Also:
      encapsulates(Block), encapsulates(BlockData)
    • asDataString

      @NotNull @NotNull String asDataString()
      Get this VeinBlock instance as a readable data String. Similar to how BlockData.getAsString() returns a human-readable representation of block data, this will return a human-readable representation of the vein block based on its defined data (if any). It will be under a similar format as the aforementioned method.
      Returns:
      the human-readable data string
    • compareTo

      default int compareTo​(@Nullable @Nullable VeinBlock other)
      Specified by:
      compareTo in interface Comparable<VeinBlock>
    • get

      @NotNull static @NotNull VeinBlock get​(@NotNull @NotNull org.bukkit.Material material)
      Get a VeinBlock based on type with no additional block states.
      Parameters:
      material - the material for which to get a VeinBlock instance
      Returns:
      the VeinBlock instance
    • get

      @NotNull static @NotNull VeinBlock get​(@NotNull @NotNull org.bukkit.block.data.BlockData data)
      Get a VeinBlock based on block data with a set of states.
      Parameters:
      data - the block data for which to get a VeinBlock instance
      Returns:
      the VeinBlock instance
    • fromString

      @Nullable static @Nullable VeinBlock fromString​(@NotNull @NotNull String value)
      Get a VeinBlock based on a String representation of its material and/or state. If the format of the String is inconsistent with how Minecraft formats its states, or if the type / (one or more of the) states are invalid or unknown, this method will return null. An example of valid formats are as follows:
      
       chest
       minecraft:chest
       minecraft:chest[waterlogged=true]
       minecraft:chest[facing=north,waterlogged=true]
       
      Parameters:
      value - the value from which to get a VeinBlock instance.
      Returns:
      the parsed VeinBlock instance. null if malformed
    • clearCache

      static void clearCache()
      Clear the VeinBlock cache. This may slightly decrease performance until the cache returns to a more populated state.