Class CustomBlockType<T extends CustomBlock>

java.lang.Object
redempt.redlib.blockdata.custom.CustomBlockType<T>
Type Parameters:
T - The type of the CustomBlock represented by this CustomBlockType
All Implemented Interfaces:
org.bukkit.event.Listener

public abstract class CustomBlockType<T extends CustomBlock> extends Object implements org.bukkit.event.Listener
Represents a type of a CustomBlock that can be set
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a CustomBlockType with the type name.
  • Method Summary

    Modifier and Type
    Method
    Description
    final T
    get(org.bukkit.block.Block block)
    Gets a CustomBlock of this type at the given block
    final T
    Gets a CustomBlock of this type from the given DataBlock
    abstract String
     
    Defines a custom return for a class extending CustomBlock
    List<org.bukkit.inventory.ItemStack>
    getDrops(T block)
     
    abstract org.bukkit.inventory.ItemStack
    getItem(T block)
    Gets the item to be dropped when this block is mined
     
    final T
    initialize(org.bukkit.block.Block block)
    Initializes the placement of this CustomBlockType for the given Block.
    boolean
    itemMatches(org.bukkit.inventory.ItemStack item)
    Checks whether the item given matches the item for this CustomBlockType
    abstract void
    place(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item, T block)
    Called when this CustomBlockType is placed.
    protected final void
     
    boolean
    typeMatches(org.bukkit.Material material)
    Checks whether the type of a block matches this CustomBlockType.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CustomBlockType

      public CustomBlockType(String typeName)
      Construct a CustomBlockType with the type name. You should only call this if you don't use CustomBlockRegistry.registerAll(Plugin) to load custom block types.
      Parameters:
      typeName - The name of this type
  • Method Details

    • itemMatches

      public boolean itemMatches(org.bukkit.inventory.ItemStack item)
      Checks whether the item given matches the item for this CustomBlockType
      Parameters:
      item - The ItemStack to check
      Returns:
      Whether the item matches
    • place

      public abstract void place(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item, T block)
      Called when this CustomBlockType is placed. Use it to initialize any fields that are needed.
      Parameters:
      player - The player who placed the CustomBlock
      item - The ItemStack in their hand when it was placed
      block - The CustomBlock storing the data
    • getItem

      public abstract org.bukkit.inventory.ItemStack getItem(T block)
      Gets the item to be dropped when this block is mined
      Parameters:
      block - The CustomBlock that was mined
      Returns:
      The ItemStack to drop
    • getDrops

      public List<org.bukkit.inventory.ItemStack> getDrops(T block)
    • getBaseItemName

      public abstract String getBaseItemName()
      Returns:
      A unique item name that the item for this CustomBlockType will have
    • register

      protected final void register(BlockDataManager manager)
    • typeMatches

      public boolean typeMatches(org.bukkit.Material material)
      Checks whether the type of a block matches this CustomBlockType. Always returns true by default.
      Parameters:
      material - The Material to check
      Returns:
      Whether this Material matches the type for this CustomBlockType
    • getName

      public String getName()
      Returns:
      The name of this CustomBlockType
    • getCustom

      public T getCustom(DataBlock db)
      Defines a custom return for a class extending CustomBlock
      Parameters:
      db - The DataBlock to be passed to the constructor
      Returns:
      The CustomBlock sub-class instance
    • get

      public final T get(org.bukkit.block.Block block)
      Gets a CustomBlock of this type at the given block
      Parameters:
      block - The Block to get the CustomBlock at
      Returns:
      The CustomBlock of this type at this Block, or null if it is not present
    • get

      public final T get(DataBlock db)
      Gets a CustomBlock of this type from the given DataBlock
      Parameters:
      db - The DataBlock to get the CustomBlock at
      Returns:
      The CustomBlock of this type represented by this DataBlock, or null if it is not present
    • initialize

      public final T initialize(org.bukkit.block.Block block)
      Initializes the placement of this CustomBlockType for the given Block. Does not change the block's vanilla type.
      Parameters:
      block - The block to initialize
      Returns:
      The initialized CustomBlock