Class BuildMcRegistryEvent

java.lang.Object
org.bukkit.event.Event
net.mathias2246.buildmc.api.event.CustomEvent
net.mathias2246.buildmc.api.event.lifecycle.BuildMcRegistryEvent

public class BuildMcRegistryEvent extends CustomEvent

The BuildMcRegistryEvent is fired once during the plugin startup lifecycle to give other plugins a chance to register or modify values in BuildMC’s registries before they are finalized and made immutable.

Why this event exists

  • The BuildMC plugin must load first to expose its API.
  • Other plugins (extensions) may want to change the behaviours of BuildMC before it starts running.
  • However, by the time BuildMC itself is fully enabled, its registries would normally be locked, leaving no safe way for extensions to hook in.

This event solves that ordering problem by deferring registry finalization until after all plugins have been enabled. Once the server signals that plugin startup is complete, BuildMC fires this event, passing its API instance. Extensions can then safely register or modify values before the registries are frozen.

How to use it


 public class MyExtensionPlugin extends JavaPlugin implements Listener {

     @Override
     public void onEnable() {
         // Register as a listener to receive BuildMcRegistryEvent
         Bukkit.getPluginManager().registerEvents(this, this);
     }

     @EventHandler
     public void onRegistry(BuildMcRegistryEvent event) {
         BuildMcAPI api = event.getApi();

         // Configure the API here...
     }
 }
 

Lifecycle

  1. BuildMC loads and initializes its API with empty, mutable registries.
  2. Other plugins enable normally and register listeners for this event.
  3. After all plugins are enabled, BuildMC fires this event once.
  4. Extensions receive the API and make their registrations.
  5. BuildMC finalizes its registries and loads the config, making them immutable for runtime.
See Also:
  • Constructor Details

    • BuildMcRegistryEvent

      public BuildMcRegistryEvent(@NotNull @NotNull BuildMcAPI api)
      Creates a new BuildMcRegistryEvent.
      Parameters:
      api - the active BuildMcAPI instance, providing access to registries and configuration
  • Method Details

    • getApi

      @NotNull public @NotNull BuildMcAPI getApi()
      Gets the BuildMC API instance.

      Extensions should use this API to add or modify registry entries during the registration phase.

      Returns:
      the BuildMC API instance
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Gets the list of handlers for this event. Required by the Bukkit event system.
      Specified by:
      getHandlers in class CustomEvent
      Returns:
      the handler list
    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()
      Gets the static list of handlers for this event type. Required by Bukkit for event registration.
      Returns:
      the handler list