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<@NotNull 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

      public void preInit()
      Pre-Initialize all plugins.
    • init

      @NotNull public void init()
      Initialize all plugins.
    • postInit

      @NotNull public void postInit(WatameBot watamebot)
      Post-Initialize all plugins.
      Parameters:
      watamebot - - reference to WatameBot that is passed on to the plugin's postInit
    • onReady

      @NotNull public @NotNull 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

      @NotNull public @NotNull 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
    • isPluginPresent

      public boolean isPluginPresent(Class<? extends @NotNull T> pluginClass)
      Check if a plugin is loaded.
      Parameters:
      pluginClass - - class of the plugin to check
      Returns:
      Returns true if the specified plugin was found
    • getPlugin

      @Nullable public T getPlugin(String identifier)
      NEED_JAVADOC
      Parameters:
      identifier -
      Returns:
      Returns the Plugin with the specified identifier
    • getPlugin

      @Nullable public T getPlugin(Class<? extends @NotNull T> pluginClass)
      Get a plugin by class.
      Parameters:
      pluginClass - - plugin class
      Returns:
      Returns the found Plugin if found, otherwise null
    • getPluginClass

      @NotNull public @NotNull 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

      @NotNull public @NotNull 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

      @NotNull public @NotNull ExecutorService getAsynchronousExecutor()
      NEED_JAVADOC
      Returns:
      Returns the thread pool used for asynchronous execution