Package redempt.redlib.blockdata.custom
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
ConstructorsConstructorDescriptionCustomBlockType(String typeName) Construct a CustomBlockType with the type name. -
Method Summary
Modifier and TypeMethodDescriptionfinal Tget(org.bukkit.block.Block block) Gets aCustomBlockof this type at the given blockfinal TGets aCustomBlockof this type from the given DataBlockabstract StringDefines a custom return for a class extendingCustomBlockList<org.bukkit.inventory.ItemStack>abstract org.bukkit.inventory.ItemStackGets the item to be dropped when this block is minedgetName()final Tinitialize(org.bukkit.block.Block block) Initializes the placement of this CustomBlockType for the given Block.booleanitemMatches(org.bukkit.inventory.ItemStack item) Checks whether the item given matches the item for this CustomBlockTypeabstract voidCalled when this CustomBlockType is placed.protected final voidregister(BlockDataManager manager) booleantypeMatches(org.bukkit.Material material) Checks whether the type of a block matches this CustomBlockType.
-
Constructor Details
-
CustomBlockType
Construct a CustomBlockType with the type name. You should only call this if you don't useCustomBlockRegistry.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 CustomBlockitem- The ItemStack in their hand when it was placedblock- The CustomBlock storing the data
-
getItem
Gets the item to be dropped when this block is mined- Parameters:
block- The CustomBlock that was mined- Returns:
- The ItemStack to drop
-
getDrops
-
getBaseItemName
- Returns:
- A unique item name that the item for this CustomBlockType will have
-
register
-
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
- Returns:
- The name of this CustomBlockType
-
getCustom
Defines a custom return for a class extendingCustomBlock- Parameters:
db- The DataBlock to be passed to the constructor- Returns:
- The CustomBlock sub-class instance
-
get
Gets aCustomBlockof 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
Gets aCustomBlockof 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
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
-