Package redempt.redlib.blockdata.custom
Class CustomBlockRegistry
java.lang.Object
redempt.redlib.blockdata.custom.CustomBlockRegistry
- All Implemented Interfaces:
org.bukkit.event.Listener
Loads and registers CustomBlockTypes
-
Constructor Summary
ConstructorDescriptionCustomBlockRegistry
(BlockDataManager manager) Construct a CustomBlockRegistry without passing a plugin.CustomBlockRegistry
(BlockDataManager manager, org.bukkit.plugin.Plugin plugin) Construct a CustomBlockRegistry, passing a plugin. -
Method Summary
Modifier and TypeMethodDescriptionstatic List<CustomBlockRegistry>
Gets a CustomBlockType by name<T extends CustomBlock>
TgetCustomBlock
(org.bukkit.block.Block block) Gets a CustomBlock instance with the correct CustomBlockTypegetTypes()
<T extends CustomBlock>
voidvoid
onClick
(org.bukkit.event.player.PlayerInteractEvent e) void
onDisable
(org.bukkit.event.server.PluginDisableEvent e) <T extends CustomBlock>
voidonPickBlock
(org.bukkit.event.inventory.InventoryCreativeEvent e) <T extends CustomBlock>
voidonPlace
(org.bukkit.event.block.BlockPlaceEvent e) void
register
(CustomBlockType<?> type) Registers a single CustomBlockType into this CustomBlockRegistryvoid
registerAll
(org.bukkit.plugin.Plugin plugin) Looks through all classes in a Plugin, registering all classes which extend CustomBlockType that are not interfaces or abstract.
-
Constructor Details
-
CustomBlockRegistry
Construct a CustomBlockRegistry without passing a plugin. Use this constructor if you plan to useregisterAll(Plugin)
.- Parameters:
manager
- The BlockDataManager to use for managing block data
-
CustomBlockRegistry
Construct a CustomBlockRegistry, passing a plugin. Use this constructor if you plan to useregister(CustomBlockType)
- Parameters:
manager
- The BlockDataManager to use for managing block dataplugin
- The Plugin to register events with
-
-
Method Details
-
getAllRegistries
- Returns:
- All active CustomBlockRegistries
-
getManager
- Returns:
- The BlockDataManager managing block data for this CustomBlockRegistry
-
registerAll
public void registerAll(org.bukkit.plugin.Plugin plugin) Looks through all classes in a Plugin, registering all classes which extend CustomBlockType that are not interfaces or abstract. Each one must have a constructor that takes no arguments in order to be registered.- Parameters:
plugin
- The Plugin to register the CustomBlockTypes with
-
register
Registers a single CustomBlockType into this CustomBlockRegistry- Parameters:
type
- The CustomBlockType to register
-
getByName
Gets a CustomBlockType by name- Parameters:
name
- The name of the CustomBlockType- Returns:
- The CustomBlockType with the given name
-
getTypes
- Returns:
- A collection of all CustomBlockTypes in this registry
-
getCustomBlock
Gets a CustomBlock instance with the correct CustomBlockType- Type Parameters:
T
- The type of the CustomBlock- Parameters:
block
- The Block to check- Returns:
- The CustomBlock, or null if it was not a custom block
-
onClick
public void onClick(org.bukkit.event.player.PlayerInteractEvent e) -
onPlace
-
onBreak
-
onPickBlock
public <T extends CustomBlock> void onPickBlock(org.bukkit.event.inventory.InventoryCreativeEvent e) -
onDisable
public void onDisable(org.bukkit.event.server.PluginDisableEvent e)
-