java.lang.Object
net.foxgenesis.watame.plugin.PluginHandler<T>
- Type Parameters:
T- - the plugin class this instance uses
- All Implemented Interfaces:
Closeable,AutoCloseable
Class used to handle all plugin related tasks.
- Author:
- Ashley
-
Constructor Summary
ConstructorsConstructorDescriptionPluginHandler(Context context, ModuleLayer layer, Class<@NotNull T> pluginClass) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close all loaded plugins and wait for the termination of the plugin thread pool.@NotNull ExecutorServiceNEED_JAVADOC@NotNull ModuleLayerGet the module layer used by this instance.NEED_JAVADOCGet the class used by this instance.@NotNull CompletableFuture<Void>init()Initialize all plugins.booleanisPluginPresent(String identifier) Check if a plugin is loaded.voidLoad all plugins from the service loader@NotNull CompletableFuture<Void>Post-Initialize all plugins.@NotNull CompletableFuture<Void>Post-Initialize all plugins.@NotNull CompletableFuture<Void>preInit()Pre-Initialize all plugins.@NotNull net.dv8tion.jda.api.requests.restaction.CommandListUpdateActionupdateCommands(net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction action) Fill aCommandListUpdateActionwill all commands specified by the loaded plugins.
-
Constructor Details
-
PluginHandler
- Parameters:
layer- - layer theServiceLoadershould usepluginClass- - the pluginClassto load
-
-
Method Details
-
loadPlugins
public void loadPlugins()Load all plugins from the service loader -
preInit
Pre-Initialize all plugins.- Returns:
- Returns a
CompletableFuturethat completes when all plugins have finished theirPlugin.preInit()
-
init
Initialize all plugins.- Returns:
- Returns a
CompletableFuturethat completes when all plugins have finished theirPlugin.init(IEventStore)
-
postInit
Post-Initialize all plugins.- Parameters:
watamebot- - reference toWatameBotthat is passed on to the plugin'spostInit- Returns:
- Returns a
CompletableFuturethat completes when all plugins have finished theirPlugin.postInit(WatameBot)
-
onReady
Post-Initialize all plugins.- Parameters:
watamebot- - reference toWatameBotthat is passed on to the plugin'sonReadyo- Returns:
- Returns a
CompletableFuturethat completes when all plugins have finished theirPlugin.onReady(WatameBot)
-
updateCommands
@NotNull public @NotNull net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction updateCommands(net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction action) Fill aCommandListUpdateActionwill all commands specified by the loaded plugins.- Parameters:
action- - update task to fill- Returns:
- Returns the action for chaining
-
close
public void close()Close all loaded plugins and wait for the termination of the plugin thread pool.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isPluginPresent
Check if a plugin is loaded.- Parameters:
identifier- - plugin identifier- Returns:
- Returns
trueif the plugin is loaded
-
getPlugin
NEED_JAVADOC- Parameters:
identifier-- Returns:
-
getPluginClass
Get the class used by this instance.- Returns:
- Returns a
Classthat is used by theServiceLoaderto load the plugins
-
getModuleLayer
Get the module layer used by this instance.- Returns:
- Returns a
ModuleLayerthat is used by theServiceLoaderto load the plugins
-
getAsynchronousExecutor
NEED_JAVADOC- Returns:
-