Interface FlectonePulse
Example usage:
// Get the FlectonePulse instance
FlectonePulse flectonePulse = FlectonePulseAPI.getInstance();
// Check if the injector is ready
if (flectonePulse.isReady()) {
// Get a dependency
FLogger logger = flectonePulse.get(FLogger.class);
logger.info("Hello world");
}
- Since:
- 0.1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidcloseUIs()Closes all open user interfaces including inventories and dialogs.default <T> TRetrieves an instance of the specified class through dependency injection.com.google.inject.InjectorGets the Google Guice Injector instance used for dependency injection.voidInitialize the PacketAdapter API.default booleanisReady()Checks if the dependency injector is ready to provide instances.voidCalled when the FlectonePulse is disabled.voidonEnable()Called when the FlectonePulse is enabled.voidreload()Reloads the FlectonePulse configuration and modules.voidTerminates PacketAdapter API if initialization failed.voidTerminates the PacketAdapter API and cleans up related resources.default voidThrows an InitException with the message from the provided exception.
-
Method Details
-
getInjector
com.google.inject.Injector getInjector()Gets the Google Guice Injector instance used for dependency injection. This injector is responsible for creating and managing instances of FlectonePulse components and services.- Returns:
- the Injector instance, or
nullif not initialized - See Also:
-
onEnable
void onEnable()Called when the FlectonePulse is enabled.This method initializes the dependency injector and prepares the FlectonePulse for operation. It should only be called by the FlectonePulse itself.
-
onDisable
void onDisable()Called when the FlectonePulse is disabled.This method cleans up resources and shuts down FlectonePulse modules. It should only be called by the FlectonePulse itself.
-
reload
Reloads the FlectonePulse configuration and modules.This method reinitializes the plugin with updated configuration files and should be called when configuration changes are made at runtime.
- Throws:
ReloadException- if an error occurs during reload- See Also:
-
initPacketAdapter
void initPacketAdapter()Initialize the PacketAdapter API. -
terminateFailedPacketAdapter
void terminateFailedPacketAdapter()Terminates PacketAdapter API if initialization failed. Prevents errors when FlectonePulse fails to start. -
terminatePacketAdapter
void terminatePacketAdapter()Terminates the PacketAdapter API and cleans up related resources. -
closeUIs
void closeUIs()Closes all open user interfaces including inventories and dialogs. -
get
Retrieves an instance of the specified class through dependency injection. Uses Google Guice as the underlying dependency injection framework.Note: Most FlectonePulse classes (except models) are marked with
@Singleton.- Type Parameters:
T- the type of instance to retrieve- Parameters:
type- the class of the instance to retrieve- Returns:
- an instance of the requested type
- Throws:
IllegalStateException- if the injector is not ready- See Also:
-
isReady
default boolean isReady()Checks if the dependency injector is ready to provide instances.Important: Always call this method before
get(Class)to ensure the injector has been properly initialized.- Returns:
trueif the injector is ready,falseotherwise- See Also:
-
throwInitException
Throws an InitException with the message from the provided exception.In production mode (when -Dflectonepulse.debug is not set to true), the error message is truncated to the first 25 lines to prevent excessive log output. In debug mode, the full exception message is preserved.
- Parameters:
e- the original exception whose message will be included in the InitException- Throws:
InitException- always thrown with the processed error message
-