- Author:
- Ashley
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal PathPath to the plugin's configuration folderfinal StringDescription of the plugin.final StringFriendly identifier of the plugin.protected final org.slf4j.LoggerPlugin loggerfinal StringName identifier of the plugin.final booleanDoes this plugin require access to the database.final booleanDoes this plugin provide commands.final Runtime.VersionVersion of the plugin. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidclose()Called when the plugin is to be unloaded.booleanprotected Collection<net.dv8tion.jda.api.interactions.commands.build.CommandData>Register allCommandDatathat this plugin provides.protected org.apache.commons.configuration2.PropertiesConfigurationgetConfiguration(String identifier) Get the configuration file that is linked to anidentifierornullif not found.protected booleanhasConfiguration(String identifier) Check if a configuration file with the specifiedidentifierexists.inthashCode()protected abstract voidinit(IEventStore builder) Startup method called when methods providing functionality are to be loaded.protected abstract voidonConfigurationLoaded(String identifier, org.apache.commons.configuration2.Configuration properties) Startup method called during construction when aConfigurationspecified by aPluginConfigurationhas been loaded.protected abstract voidonPropertiesLoaded(Properties properties) Startup method called during construction when theplugin.propertiesfile has been loaded.protected abstract voidCalled by thePluginHandlerwhenJDAand allPluginshave finished startup and have finished loading.protected abstract voidStartup method called whenJDAis building a connection to discord and allCommandDatais being collected fromgetCommands().protected abstract voidpreInit()Startup method called when resources, needed for functionality initialization, are to be loaded.protected voidregisterDatabases(IDatabaseManager manager) Register custom databases.toString()
-
Field Details
-
logger
@Nonnull protected final org.slf4j.Logger loggerPlugin logger -
configurationPath
Path to the plugin's configuration folder -
name
Name identifier of the plugin. -
friendlyName
Friendly identifier of the plugin. -
description
Description of the plugin. -
version
Version of the plugin. -
providesCommands
public final boolean providesCommandsDoes this plugin provide commands. -
needsDatabase
public final boolean needsDatabaseDoes this plugin require access to the database.
-
-
Constructor Details
-
Plugin
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 theplugin.propertiesfile
-
-
Method Details
-
hasConfiguration
Check if a configuration file with the specifiedidentifierexists.- Parameters:
identifier- - thePluginConfiguration.identifier()- Returns:
- Returns
trueif the specifiedidentifierpoints to a valid configuration
-
getConfiguration
@Nullable protected org.apache.commons.configuration2.PropertiesConfiguration getConfiguration(String identifier) Get the configuration file that is linked to anidentifierornullif not found.- Parameters:
identifier- - thePluginConfiguration.identifier()- Returns:
- Returns the
PropertiesConfigurationlinked to theidentifier
-
getCommands
@Nonnull protected Collection<net.dv8tion.jda.api.interactions.commands.build.CommandData> getCommands()Register allCommandDatathat this plugin provides.**
providesCommandsmust be set to true inplugin.properties! **- Returns:
- Returns a non-null
CollectionofCommandDatathat thisPluginprovides
-
registerDatabases
Register custom databases.**
needsDatabasemust be set to true inplugin.properties! **- Parameters:
manager- - database manager
-
onPropertiesLoaded
Startup method called during construction when theplugin.propertiesfile has been loaded.DO NOT BLOCK IN THIS METHOD!
- Parameters:
properties- - properties loaded fromplugin.properties- See Also:
-
onConfigurationLoaded
protected abstract void onConfigurationLoaded(String identifier, org.apache.commons.configuration2.Configuration properties) Startup method called during construction when aConfigurationspecified by aPluginConfigurationhas been loaded.DO NOT BLOCK IN THIS METHOD!
- Parameters:
identifier- - thePluginConfiguration.identifier()properties- - the loadedConfiguration- See Also:
-
preInit
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 (guild settings) 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:
- Custom database registration
- SQL compiled statements
- System Data
- Files
- Images
- Throws:
SeverePluginException- Thrown if the plugin has encountered a severe exception. If the exception is fatal, the plugin will be unloaded- See Also:
-
init
Startup method called when methods providing functionality are to be loaded. Methods that require connection to Discord or the database should be called here.Database (guild settings) and Discord information might not be loaded at the time of this method! Use
onReady(WatameBot)for functionality that requires valid connections.Typical methods to call here include:
- Event listener registration
- Custom database operations
- Parameters:
builder- - discord event listener register- Throws:
SeverePluginException- Thrown if the plugin has encountered a severe exception. If the exception is fatal, the plugin will be unloaded- See Also:
-
postInit
Startup method called whenJDAis building a connection to discord and allCommandDatais being collected fromgetCommands().Database (guild settings) and Discord information might not be loaded at the time of this method! Use
onReady(WatameBot)for functionality that requires valid connections.- Parameters:
bot- - reference ofWatameBot- Throws:
SeverePluginException- Thrown if the plugin has encountered a severe exception. If the exception is fatal, the plugin will be unloaded
-
onReady
Called by thePluginHandlerwhenJDAand allPluginshave finished startup and have finished loading.- Parameters:
bot- - reference ofWatameBot- Throws:
SeverePluginException- Thrown if the plugin has encountered a severe exception. If the exception is fatal, the plugin will be unloaded- See Also:
-
close
Called when the plugin is to be unloaded.The shutdown sequence runs as followed:
- Remove event listeners
close()- Close databases
- Throws:
Exception- Thrown if an underlying exception is thrown during close
-
getDisplayInfo
-
toString
-
hashCode
public int hashCode() -
equals
-