Class Addon
- Direct Known Subclasses:
HollowAddon
The Addon class serves as a base for creating custom addons. Subclasses of Addon must
implement the onEnable() and onDisable() methods to define the behavior when the addon is
enabled or disabled, respectively. The onLoad() method can be optionally overridden to perform actions
during addon loading.
Each addon has access to a RouteRegistry instance for handling routes and a ListenerRegistry
instance for registering listeners within the addon. It also has a Logger instance for logging messages
specific to the addon and a ServiceManager for registering service loaders.
The Addon class provides a convenient way to extend the application's capabilities through custom
functionality, making it easy to add new features or modify existing ones without directly altering the application's
core code.
- Since:
- 1.0.0-SNAPSHOT
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal AutoRegisterRegistryDeprecated, for removal: This API element is subject to removal in a future version.final BodyRegistryDeprecated, for removal: This API element is subject to removal in a future version.UsegetBodyRegistry()instead.final CommandRegistryDeprecated, for removal: This API element is subject to removal in a future version.UsegetCommandRegistry()instead.final CraftsNetDeprecated, for removal: This API element is subject to removal in a future version.UsegetCraftsNet()instead.<T extends Addon>
TRetrieves an addon of the specified type from the loaded addons.<T extends Addon>
TRetrieves an addon by its name from the loaded addons.final AddonManagerRetrieves theAddonManagerinstance used by the addon.final AutoRegisterRegistryRetrieves theAutoRegisterRegistryinstance used by the addon.final BodyRegistryGet theBodyRegistryinstance used by the addon.final ClassLoaderGet the class loader instance used by the addon.final CommandRegistryGet theCommandRegistryinstance used by the addon.Get the CraftsNet instance on which the addon was registered.final FileRetrieves the data folder for this addon as aFileobject.final PathRetrieves the data directory for this addon as aPath.final FileHelperGet theFileHelperinstance used by the addon.final de.craftsblock.craftscore.event.ListenerRegistryGet theListenerRegistryinstance used by the addon.Get the logger instance used by the addon.final LogStreamGet theLogStreaminstance used by the addon.getMeta()Get the metadata of the addon.final MiddlewareRegistryGet theMiddlewareRegistryinstance used by the addon.final StringgetName()Get the name of the addon.final RequirementRegistryGet theRequirementRegistryinstance used by the addon.final RouteRegistryGet theRouteRegistryinstance used by the addon.final ServiceManagerGet theServiceManagerinstance used by the addon.final StreamEncoderRegistryGet theStreamEncoderRegistryinstance used by the addon.final TypeEncoderRegistry<WebSocketSafeTypeEncoder<?,?>> Retrieves theTypeEncoderRegistrydedicated to managingWebSocketSafeTypeEncoderinstances used by theWebSocketServer.Retrieves theWebSocketExtensionRegistryinstance used by the addon.final de.craftsblock.craftscore.event.ListenerRegistryDeprecated, for removal: This API element is subject to removal in a future version.UsegetListenerRegistry()instead.final Loggerlogger()Deprecated, for removal: This API element is subject to removal in a future version.UsegetLogger()instead.final MiddlewareRegistryDeprecated, for removal: This API element is subject to removal in a future version.UsegetMiddlewareRegistry()instead.voidCalled when the addon is being disabled.voidonEnable()Called when the addon is being enabled.voidonLoad()Called when the addon is being loaded.final RequirementRegistryDeprecated, for removal: This API element is subject to removal in a future version.UsegetRequirementRegistry()instead.final RouteRegistryDeprecated, for removal: This API element is subject to removal in a future version.UsegetRouteRegistry()instead.final ServiceManagerDeprecated, for removal: This API element is subject to removal in a future version.UsegetServiceManager()instead.final StreamEncoderRegistryDeprecated, for removal: This API element is subject to removal in a future version.UsegetStreamEncoderRegistry()instead.
-
Constructor Details
-
Addon
public Addon()
-
-
Method Details
-
onLoad
public void onLoad()Called when the addon is being loaded. This method can be overridden to perform any setup or initialization tasks. -
onEnable
public void onEnable()Called when the addon is being enabled. This method must be implemented by subclasses to define the addon's functionality. -
onDisable
public void onDisable()Called when the addon is being disabled. This method must be implemented by subclasses to clean up any resources or perform any necessary shutdown tasks. -
craftsNet
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final CraftsNet craftsNet()Deprecated, for removal: This API element is subject to removal in a future version.UsegetCraftsNet()instead. This will be removed in the future.Get the CraftsNet instance on which the addon was registered. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The CraftsNet instance on which the addon was registered.
- Since:
- 3.1.0-SNAPSHOT
-
getCraftsNet
Get the CraftsNet instance on which the addon was registered. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The CraftsNet instance on which the addon was registered.
- Since:
- 3.1.0-SNAPSHOT
-
getName
Get the name of the addon.- Returns:
- The name of the addon.
-
getMeta
Get the metadata of the addon.- Returns:
- The metadata of the addon.
- Since:
- 3.1.0-SNAPSHOT
-
getAddonManager
Retrieves theAddonManagerinstance used by the addon. This method is marked as final to prevent subclasses from modifying it directly.- Returns:
- The
AddonManagerinstance used by the addon. - Since:
- 3.1.0-SNAPSHOT
-
autoRegisterRegistry
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final AutoRegisterRegistry autoRegisterRegistry()Deprecated, for removal: This API element is subject to removal in a future version.UsegetAutoRegisterRegistry()instead. This will be removed in the future.Retrieves theAutoRegisterRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
AutoRegisterRegistryinstance used by the addon. - Since:
- 3.2.0-SNAPSHOT
-
getAutoRegisterRegistry
Retrieves theAutoRegisterRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
AutoRegisterRegistryinstance used by the addon. - Since:
- 3.2.0-SNAPSHOT
-
bodyRegistry
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final BodyRegistry bodyRegistry()Deprecated, for removal: This API element is subject to removal in a future version.UsegetBodyRegistry()instead. This will be removed in the future.Get theBodyRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
BodyRegistryinstance used by the addon. - Since:
- 3.0.4-SNAPSHOT
-
getBodyRegistry
Get theBodyRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
BodyRegistryinstance used by the addon. - Since:
- 3.0.4-SNAPSHOT
-
commandRegistry
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final CommandRegistry commandRegistry()Deprecated, for removal: This API element is subject to removal in a future version.UsegetCommandRegistry()instead. This will be removed in the future.Get theCommandRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
CommandRegistryinstance used by the addon.
-
getCommandRegistry
Get theCommandRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
CommandRegistryinstance used by the addon.
-
getFileHelper
Get theFileHelperinstance used by the addon. This method is marked as final to prevent subclasses from modifying it directly.- Returns:
- The
FileHelperinstance used by the addon.
-
listenerRegistry
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final de.craftsblock.craftscore.event.ListenerRegistry listenerRegistry()Deprecated, for removal: This API element is subject to removal in a future version.UsegetListenerRegistry()instead. This will be removed in the future.Get theListenerRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
ListenerRegistryinstance used by the addon.
-
getListenerRegistry
public final de.craftsblock.craftscore.event.ListenerRegistry getListenerRegistry()Get theListenerRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
ListenerRegistryinstance used by the addon.
-
getLogStream
Get theLogStreaminstance used by the addon. This method is marked as final to prevent subclasses from modifying it directly.- Returns:
- The
LogStreaminstance used by the addon.
-
middlewareRegistry
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final MiddlewareRegistry middlewareRegistry()Deprecated, for removal: This API element is subject to removal in a future version.UsegetMiddlewareRegistry()instead. This will be removed in the future.Get theMiddlewareRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
MiddlewareRegistryinstance used by the addon. - Since:
- 3.4.0-SNAPSHOT
-
getMiddlewareRegistry
Get theMiddlewareRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
MiddlewareRegistryinstance used by the addon. - Since:
- 3.4.0-SNAPSHOT
-
requirementRegistry
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final RequirementRegistry requirementRegistry()Deprecated, for removal: This API element is subject to removal in a future version.UsegetRequirementRegistry()instead. This will be removed in the future.Get theRequirementRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
RequirementRegistryinstance used by the addon. - Since:
- 3.2.1-SNAPSHOT
-
getRequirementRegistry
Get theRequirementRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the registry directly.- Returns:
- The
RequirementRegistryinstance used by the addon. - Since:
- 3.2.1-SNAPSHOT
-
routeRegistry
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final RouteRegistry routeRegistry()Deprecated, for removal: This API element is subject to removal in a future version.UsegetRouteRegistry()instead. This will be removed in the future.Get theRouteRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the handler directly.- Returns:
- The
RouteRegistryinstance used by the addon.
-
getRouteRegistry
Get theRouteRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the handler directly.- Returns:
- The
RouteRegistryinstance used by the addon.
-
serviceManager
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final ServiceManager serviceManager()Deprecated, for removal: This API element is subject to removal in a future version.UsegetServiceManager()instead. This will be removed in the future.Get theServiceManagerinstance used by the addon. This method is marked as final to prevent subclasses from modifying the handler directly.- Returns:
- The
ServiceManagerinstance used by the addon.
-
getServiceManager
Get theServiceManagerinstance used by the addon. This method is marked as final to prevent subclasses from modifying the handler directly.- Returns:
- The
ServiceManagerinstance used by the addon.
-
streamEncoderRegistry
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final StreamEncoderRegistry streamEncoderRegistry()Deprecated, for removal: This API element is subject to removal in a future version.UsegetStreamEncoderRegistry()instead. This will be removed in the future.Get theStreamEncoderRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the handler directly.- Returns:
- The
StreamEncoderRegistryinstance used by the addon. - Since:
- 3.3.3-SNAPSHOT
-
getStreamEncoderRegistry
Get theStreamEncoderRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying the handler directly.- Returns:
- The
StreamEncoderRegistryinstance used by the addon. - Since:
- 3.3.3-SNAPSHOT
-
getWebSocketEncoderRegistry
Retrieves theTypeEncoderRegistrydedicated to managingWebSocketSafeTypeEncoderinstances used by theWebSocketServer.- Returns:
- the
TypeEncoderRegistryforWebSocketSafeTypeEncodercodecs
-
getWebsocketExtensionRegistry
Retrieves theWebSocketExtensionRegistryinstance used by the addon. This method is marked as final to prevent subclasses from modifying it directly.- Returns:
- The
WebSocketExtensionRegistryinstance used by the addon. - Since:
- 3.5.0
-
getClassLoader
Get the class loader instance used by the addon. This method is marked as final to prevent subclasses from modifying the handler directly.- Returns:
- The class loader used by this addon.
-
logger
@Deprecated(since="3.5.0", forRemoval=true) @ScheduledForRemoval(inVersion="3.6.0") public final Logger logger()Deprecated, for removal: This API element is subject to removal in a future version.UsegetLogger()instead. This will be removed in the future.Get the logger instance used by the addon. This method is marked as final to prevent subclasses from modifying the logger directly.- Returns:
- The logger instance used by the addon.
-
getLogger
Get the logger instance used by the addon. This method is marked as final to prevent subclasses from modifying the logger directly.- Returns:
- The logger instance used by the addon.
-
getDataFolder
Retrieves the data folder for this addon as aFileobject.The folder location is determined by
getDataPath(), which ensures the directory exists before returning it. This method is a convenience wrapper to convert thePathinto aFile.- Returns:
- The data folder for this addon as a
File
-
getDataPath
Retrieves the data directory for this addon as aPath.The path is resolved relative to the
addonsdirectory, using the addon's name as the subdirectory name. If the directory does not exist, it will be created. If the resolved path exists but is not a directory, anIllegalStateExceptionwill be thrown.- Returns:
- The data path for this add-on
- Throws:
RuntimeException- If the data path cannot be created or accessedIllegalStateException- If the resolved path exists but is not a directory- Since:
- 3.5.2
-
getAddon
Retrieves an addon of the specified type from the loaded addons.- Type Parameters:
T- The type of the addon to retrieve, extending the Addon class.- Parameters:
addon- The class object representing the type of the addon to be retrieved.- Returns:
- An instance of the specified addon type if found, or
nullif not present.
-
getAddon
Retrieves an addon by its name from the loaded addons.- Type Parameters:
T- The type of the addon to retrieve, extending the Addon class.- Parameters:
name- The name of the addon to be retrieved.- Returns:
- An instance of the specified addon type if found, or
nullif not present. - Since:
- 3.3.5-SNAPSHOT
-
getAutoRegisterRegistry()instead.