Module watamebot

Class Plugin

java.lang.Object
net.foxgenesis.watame.plugin.Plugin
All Implemented Interfaces:
AutoCloseable

public abstract class Plugin extends Object implements AutoCloseable
NEED_JAVADOC
Author:
Ashley
  • Field Details

    • logger

      @Nonnull protected final org.slf4j.Logger logger
      Plugin logger
    • configurationPath

      @Nonnull public final Path configurationPath
      Path to the plugin's configuration folder
    • name

      @Nonnull public final String name
      Name identifier of the plugin.
    • friendlyName

      @Nonnull public final String friendlyName
      Friendly identifier of the plugin.
    • description

      @Nonnull public final String description
      Description of the plugin.
    • version

      @Nonnull public final Runtime.Version version
      Version of the plugin.
    • providesCommands

      public final boolean providesCommands
      Does this plugin provide commands.
    • needsDatabase

      public final boolean needsDatabase
      Does this plugin require access to the database.
  • Constructor Details

    • Plugin

      public Plugin() throws SeverePluginException
      No-arg constructor to load and initialize required plugin data.
      Throws:
      SeverePluginException - if the plugin is not in a named module or there was a problem while loading the plugin.properties file
  • Method Details

    • hasConfiguration

      protected boolean hasConfiguration(String identifier)
      Check if a configuration file with the specified identifier exists.
      Parameters:
      identifier - - the PluginConfiguration.identifier()
      Returns:
      Returns true if the specified identifier points to a valid configuration
    • getConfiguration

      @Nullable protected org.apache.commons.configuration2.PropertiesConfiguration getConfiguration(String identifier)
      Get the configuration file that is linked to an identifier or null if not found.
      Parameters:
      identifier - - the PluginConfiguration.identifier()
      Returns:
      Returns the PropertiesConfiguration linked to the identifier
    • hasCommandData

      protected boolean hasCommandData(String command)
    • getCommandData

      @Nullable protected net.dv8tion.jda.api.interactions.commands.build.CommandData getCommandData(String command)
    • getCommands

      @Nonnull protected Collection<net.dv8tion.jda.api.interactions.commands.build.CommandData> getCommands()
    • onPropertiesLoaded

      protected abstract void onPropertiesLoaded(Properties properties)
    • onConfigurationLoaded

      protected abstract void onConfigurationLoaded(String identifier, org.apache.commons.configuration2.PropertiesConfiguration properties)
    • preInit

      protected abstract void preInit() throws SeverePluginException
      Startup method called when resources, needed for functionality initialization, are to be loaded. Resources that do not require connection to Discord or the database should be loaded here.

      Database and Discord information might not be loaded at the time of this method! Use onReady(WatameBot) for functionality that requires valid connections.

      Typical resources to load here include:

      • SQL compiled statements
      • System Data
      • Files
      • Images
      Throws:
      SeverePluginException
      See Also:
    • init

      protected abstract void init(ProtectedJDABuilder builder) throws SeverePluginException
      Throws:
      SeverePluginException
    • postInit

      protected abstract void postInit(WatameBot bot) throws SeverePluginException
      Throws:
      SeverePluginException
    • onReady

      protected abstract void onReady(WatameBot bot) throws SeverePluginException
      Throws:
      SeverePluginException
    • getDisplayInfo

      public String getDisplayInfo()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object