Class DeferredRegistry<T>
java.lang.Object
com.github.darksoulq.abyssallib.server.registry.DeferredRegistry<T>
- Type Parameters:
T- The type of objects handled by this registry.
A specialized registry utility that defers object registration until the server is ready.
This pattern allows developers to define registry entries in static fields before the
underlying
Registry is fully initialized. When apply() is called,
all queued entries are instantiated and moved into the main registry.-
Method Summary
Modifier and TypeMethodDescriptionvoidapply()Finalizes the registration process by moving all deferred entries into the master registry.static <T> DeferredRegistry<T> Factory method to create a new deferred registry instance.Retrieves an unmodifiable collection of all pending holders in this registry.Retrieves the namespace associated with this deferred registry.Queues an object for registration.static voidregisterModifier(Supplier<DeferredRegistryModifier> modifierFactory) Registers a custom modifier factory to dynamically intercept and handle external registration side effects (e.g., blocks automatically registering item forms).
-
Method Details
-
registerModifier
Registers a custom modifier factory to dynamically intercept and handle external registration side effects (e.g., blocks automatically registering item forms).- Parameters:
modifierFactory- The supplier providing instances of the custom modifier.
-
create
Factory method to create a new deferred registry instance.- Type Parameters:
T- The registry type.- Parameters:
registry- The baseRegistryinstance.pluginId- The namespace for the objects.- Returns:
- A new
DeferredRegistryinstance.
-
register
Queues an object for registration.- Parameters:
name- The unique name (path) within this registry's namespace.supplier- A function that creates the object using the generatedKey.- Returns:
- A
Tregistered object. - Throws:
IllegalStateException- If the name has already been registered in this deferred registry.
-
apply
public void apply()Finalizes the registration process by moving all deferred entries into the master registry. This method runs all mappedDeferredRegistryModifierrules. -
getEntries
Retrieves an unmodifiable collection of all pending holders in this registry.- Returns:
- A collection of
Holderentries.
-
getPluginId
Retrieves the namespace associated with this deferred registry.- Returns:
- The plugin or mod namespace string.
-