Class CustomBlockRegistry

java.lang.Object
redempt.redlib.blockdata.custom.CustomBlockRegistry
All Implemented Interfaces:
org.bukkit.event.Listener

public class CustomBlockRegistry extends Object implements org.bukkit.event.Listener
Loads and registers CustomBlockTypes
  • Constructor Details

    • CustomBlockRegistry

      public CustomBlockRegistry(BlockDataManager manager)
      Construct a CustomBlockRegistry without passing a plugin. Use this constructor if you plan to use registerAll(Plugin).
      Parameters:
      manager - The BlockDataManager to use for managing block data
    • CustomBlockRegistry

      public CustomBlockRegistry(BlockDataManager manager, org.bukkit.plugin.Plugin plugin)
      Construct a CustomBlockRegistry, passing a plugin. Use this constructor if you plan to use register(CustomBlockType)
      Parameters:
      manager - The BlockDataManager to use for managing block data
      plugin - The Plugin to register events with
  • Method Details

    • getAllRegistries

      public static List<CustomBlockRegistry> getAllRegistries()
      Returns:
      All active CustomBlockRegistries
    • getManager

      public BlockDataManager 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

      public void register(CustomBlockType<?> type)
      Registers a single CustomBlockType into this CustomBlockRegistry
      Parameters:
      type - The CustomBlockType to register
    • getByName

      public CustomBlockType<?> getByName(String name)
      Gets a CustomBlockType by name
      Parameters:
      name - The name of the CustomBlockType
      Returns:
      The CustomBlockType with the given name
    • getTypes

      public Collection<CustomBlockType<?>> getTypes()
      Returns:
      A collection of all CustomBlockTypes in this registry
    • getCustomBlock

      public <T extends CustomBlock> T getCustomBlock(org.bukkit.block.Block block)
      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

      public <T extends CustomBlock> void onPlace(org.bukkit.event.block.BlockPlaceEvent e)
    • onBreak

      public <T extends CustomBlock> void onBreak(DataBlockDestroyEvent e)
    • onPickBlock

      public <T extends CustomBlock> void onPickBlock(org.bukkit.event.inventory.InventoryCreativeEvent e)
    • onDisable

      public void onDisable(org.bukkit.event.server.PluginDisableEvent e)