Class AutoRegisterRegistry
java.lang.Object
de.craftsblock.craftsnet.autoregister.AutoRegisterRegistry
The
AutoRegisterRegistry is responsible for managing and invoking AutoRegisterHandler instances
based on the provided AutoRegisterInfo. The registry allows registering and unregistering handlers
and ensures that the appropriate handlers are invoked when AutoRegister information is processed.
This registry supports handling different classes based on their parent types, invoking handlers that match
the parent type of the AutoRegisterInfo. Handlers are registered using a generic approach and are responsible
for performing the actual registration logic.
- Since:
- 3.2.0-SNAPSHOT
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAutoRegisterRegistry(CraftsNet craftsNet) Constructs anAutoRegisterRegistrythat will register default handlers. -
Method Summary
Modifier and TypeMethodDescriptionbooleanhandle(AutoRegisterInfo info, Object... args) Handles a singleAutoRegisterInfoby invoking the appropriate handler(s) based on its parent types.voidhandleAll(List<AutoRegisterInfo> infos, Object... args) Handles a list ofAutoRegisterInfoby delegating to the appropriate handlers.<T> voidregister(AutoRegisterHandler<? extends T> handler) Registers a customAutoRegisterHandler.<T> booleanunregister(AutoRegisterHandler<T> handler) Unregisters the specifiedAutoRegisterHandler.<T> AutoRegisterHandler<T>unregister(Class<T> type) Unregisters anAutoRegisterHandlerby its type.
-
Constructor Details
-
AutoRegisterRegistry
Constructs anAutoRegisterRegistrythat will register default handlers.- Parameters:
craftsNet- The mainCraftsNetinstance.
-
-
Method Details
-
register
Registers a customAutoRegisterHandler. This handler will be used to handleAutoRegisterInfoof the specified type.- Type Parameters:
T- The type of handler to register.- Parameters:
handler- The handler to register.
-
unregister
Unregisters anAutoRegisterHandlerby its type.- Type Parameters:
T- The type of handler.- Parameters:
type- The class type of the handler to unregister.- Returns:
- The unregistered handler, or null if no handler was registered for this type.
-
unregister
Unregisters the specifiedAutoRegisterHandler.- Type Parameters:
T- The type of handler.- Parameters:
handler- The handler to unregister.- Returns:
- true if the handler was unregistered, false if the handler was not found.
-
handleAll
Handles a list ofAutoRegisterInfoby delegating to the appropriate handlers. EachAutoRegisterInfois passed to the matching handler based on its parent types.- Parameters:
infos- The list of AutoRegisterInfo to handle.args- The args that should be applied to theAutoRegisterHandler.
-
handle
Handles a singleAutoRegisterInfoby invoking the appropriate handler(s) based on its parent types.- Parameters:
info- The AutoRegisterInfo to handle.args- The args that should be applied to theAutoRegisterHandler.- Returns:
- true if the AutoRegisterInfo was successfully handled, false otherwise.
-