Class BuildMcRegistryEvent
java.lang.Object
org.bukkit.event.Event
net.mathias2246.buildmc.api.event.CustomEvent
net.mathias2246.buildmc.api.event.lifecycle.BuildMcRegistryEvent
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
- BuildMC loads and initializes its API with empty, mutable registries.
- Other plugins enable normally and register listeners for this event.
- After all plugins are enabled, BuildMC fires this event once.
- Extensions receive the API and make their registrations.
- BuildMC finalizes its registries and loads the config, making them immutable for runtime.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Field Summary
Fields inherited from class net.mathias2246.buildmc.api.event.CustomEvent
metadataHolder -
Constructor Summary
ConstructorsConstructorDescriptionBuildMcRegistryEvent(@NotNull BuildMcAPI api) Creates a newBuildMcRegistryEvent. -
Method Summary
Modifier and TypeMethodDescription@NotNull BuildMcAPIgetApi()Gets the BuildMC API instance.static org.bukkit.event.HandlerListGets the static list of handlers for this event type.@NotNull org.bukkit.event.HandlerListGets the list of handlers for this event.Methods inherited from class net.mathias2246.buildmc.api.event.CustomEvent
getMetadata, putMetadata, removeMetadataMethods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
Constructor Details
-
BuildMcRegistryEvent
Creates a newBuildMcRegistryEvent.- Parameters:
api- the activeBuildMcAPIinstance, providing access to registries and configuration
-
-
Method Details
-
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:
getHandlersin classCustomEvent- 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
-