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.
-
Method Details
-
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. Instead of returning the object directly, this returns aHolder, which allows for lazy initialization and safe cross-referencing during static init.- 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 triggers the instantiation of allHolderobjects and handles secondary registration for blocks and items. -
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.
-