Module watamebot

Class PluginHandler<T extends Plugin>

java.lang.Object
net.foxgenesis.watame.plugin.PluginHandler<T>
Type Parameters:
T - - the plugin class this instance uses
All Implemented Interfaces:
Closeable, AutoCloseable

public class PluginHandler<T extends Plugin> extends Object implements Closeable
Class used to handle all plugin related tasks.
Author:
Ashley
  • Constructor Details

  • Method Details

    • loadPlugins

      public void loadPlugins()
      Load all plugins from the service loader
    • preInit

      @Nonnull public CompletableFuture<Void> preInit()
      Pre-Initialize all plugins.
      Returns:
      Returns a CompletableFuture that completes when all plugins have finished their Plugin.preInit()
    • init

      @Nonnull public CompletableFuture<Void> init()
      Initialize all plugins.
      Returns:
      Returns a CompletableFuture that completes when all plugins have finished their Plugin.init(IEventStore)
    • postInit

      @Nonnull public CompletableFuture<Void> postInit(WatameBot watamebot)
      Post-Initialize all plugins.
      Parameters:
      watamebot - - reference to WatameBot that is passed on to the plugin's postInit
      Returns:
      Returns a CompletableFuture that completes when all plugins have finished their Plugin.postInit(WatameBot)
    • onReady

      @Nonnull public CompletableFuture<Void> onReady(WatameBot watamebot)
      Post-Initialize all plugins.
      Parameters:
      watamebot - - reference to WatameBot that is passed on to the plugin's onReadyo
      Returns:
      Returns a CompletableFuture that completes when all plugins have finished their Plugin.onReady(WatameBot)
    • updateCommands

      @Nonnull public net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction updateCommands(net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction action)
      Fill a CommandListUpdateAction will 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:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • isPluginPresent

      public boolean isPluginPresent(String identifier)
      Check if a plugin is loaded.
      Parameters:
      identifier - - plugin identifier
      Returns:
      Returns true if the plugin is loaded
    • getPlugin

      public T getPlugin(String identifier)
      NEED_JAVADOC
      Parameters:
      identifier -
      Returns:
    • getPluginClass

      @Nonnull public Class<T> getPluginClass()
      Get the class used by this instance.
      Returns:
      Returns a Class that is used by the ServiceLoader to load the plugins
    • getModuleLayer

      @Nonnull public ModuleLayer getModuleLayer()
      Get the module layer used by this instance.
      Returns:
      Returns a ModuleLayer that is used by the ServiceLoader to load the plugins
    • getAsynchronousExecutor

      @Nonnull public ExecutorService getAsynchronousExecutor()
      NEED_JAVADOC
      Returns: