Package io.manebot.plugin
Interface Plugin
-
public interface Plugin
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Plugin.Builder
Plugin instance Builderstatic class
Plugin.Future
static interface
Plugin.PluginFunction
-
Method Summary
Modifier and Type Method Description default Plugin
depend(ManifestIdentifier identifier)
Depends on a plugin, enabling it if possible.Artifact
getArtifact()
Gets the artifact associated with this plugin.java.util.Collection<ArtifactDependency>
getArtifactDependencies()
Gets a collection of plugins artifact dependencies of this plugin.java.util.Collection<ArtifactDependency>
getArtifactDependers()
Gets a collection of plugins artifact dependers of this plugin.Bot
getBot()
Gets the instance of the bot that is hosting this plugin.java.util.Collection<java.lang.String>
getCommands()
Gets the registered command labels for this plugin.java.util.Collection<Database>
getDatabases()
Gets a collection of Databases registered by this plugin.java.util.Collection<Plugin>
getDependencies()
Gets a collection of dependencies associated with this plugin.default Plugin
getDependentPlugin(ManifestIdentifier identifier)
Gets a dependent plugin by its manifest identifier.java.util.Collection<Plugin>
getDependers()
Gets a collection of plugins depending on this plugin.<T extends PluginReference>
TgetInstance(java.lang.Class<? extends T> instanceClass)
Gets an instance provided by the specified Plugin.java.util.logging.Logger
getLogger()
Gets the logger associated with this plugin.java.lang.String
getName()
Gets this plugin's name.default Platform
getPlatformById(java.lang.String id)
Gets a platform by its ID.java.util.Collection<Platform>
getPlatforms()
Gets a list of platforms registered by this plugin.default java.lang.String
getProperty(java.lang.String name)
Gets the value for a specific plugin property.default java.lang.String
getProperty(java.lang.String name, java.lang.String defaultValue)
Gets the value for a specific plugin property.PluginRegistration
getRegistration()
Gets the registration used to map this Plugin object to the system.java.util.Collection<Plugin>
getRequiredDependencies()
Gets a collection of required dependencies associated with this plugin.PluginType
getType()
Gets the type of plugin this plugin is assuming.boolean
isEnabled()
Finds if this plugin is enabled.default java.lang.String
requireProperty(java.lang.String name)
Gets the value for a specific plugin property.boolean
setEnabled(boolean enabled)
Sets this artifact's enabled state.
-
-
-
Method Detail
-
getBot
Bot getBot()
Gets the instance of the bot that is hosting this plugin.- Returns:
- Bot instance.
-
getInstance
<T extends PluginReference> T getInstance(java.lang.Class<? extends T> instanceClass)
Gets an instance provided by the specified Plugin.- Type Parameters:
T
- Type to return- Parameters:
instanceClass
- Instance class to look for.- Returns:
- Instance
-
getRegistration
PluginRegistration getRegistration()
Gets the registration used to map this Plugin object to the system.- Returns:
- PluginRegistration instance.
-
getArtifact
Artifact getArtifact()
Gets the artifact associated with this plugin.- Returns:
- associated Artifact instance.
-
getRequiredDependencies
java.util.Collection<Plugin> getRequiredDependencies()
Gets a collection of required dependencies associated with this plugin.- Returns:
- Required plugin dependencies.
-
getType
PluginType getType()
Gets the type of plugin this plugin is assuming.- Returns:
- plugin type.
-
getDependencies
java.util.Collection<Plugin> getDependencies()
Gets a collection of dependencies associated with this plugin.- Returns:
- Plugin dependencies.
-
getArtifactDependencies
java.util.Collection<ArtifactDependency> getArtifactDependencies()
Gets a collection of plugins artifact dependencies of this plugin.- Returns:
- Plugin artifact dependencies.
-
getDependers
java.util.Collection<Plugin> getDependers()
Gets a collection of plugins depending on this plugin.- Returns:
- Plugin dependers.
-
getArtifactDependers
java.util.Collection<ArtifactDependency> getArtifactDependers()
Gets a collection of plugins artifact dependers of this plugin.- Returns:
- Plugin artifact dependers.
-
getDependentPlugin
default Plugin getDependentPlugin(ManifestIdentifier identifier)
Gets a dependent plugin by its manifest identifier.- Parameters:
identifier
- manifest identifier to search for in this plugin's dependencies.- Returns:
- Plugin instance representing the dependent plugin described by the given identifier.
-
depend
default Plugin depend(ManifestIdentifier identifier) throws PluginException
Depends on a plugin, enabling it if possible.- Parameters:
identifier
- Identifier.- Returns:
- Plugin instance of the desired dependency.
- Throws:
PluginException
-
getPlatforms
java.util.Collection<Platform> getPlatforms()
Gets a list of platforms registered by this plugin.- Returns:
- associated Platform instances.
-
getPlatformById
default Platform getPlatformById(java.lang.String id)
Gets a platform by its ID.- Parameters:
id
- platform ID.- Returns:
- Platform instance if found, null otherwise.
-
getDatabases
java.util.Collection<Database> getDatabases()
Gets a collection of Databases registered by this plugin.- Returns:
- collection of associated databases.
-
getCommands
java.util.Collection<java.lang.String> getCommands()
Gets the registered command labels for this plugin.- Returns:
- registered commands.
-
requireProperty
default java.lang.String requireProperty(java.lang.String name) throws java.lang.IllegalArgumentException
Gets the value for a specific plugin property.- Parameters:
name
- name of the property to require.- Returns:
- property value.
- Throws:
java.lang.IllegalArgumentException
- if the property is not defined, or is defined null.
-
getProperty
default java.lang.String getProperty(java.lang.String name)
Gets the value for a specific plugin property.- Parameters:
name
- name of the property to require.- Returns:
- property value, or null if it is not defined.
-
getProperty
default java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
Gets the value for a specific plugin property.- Parameters:
name
- name of the property to obtain.defaultValue
- default value when no value does exist.- Returns:
- property value, or defaultValue if the property does not yet exist, or is defined null.
-
getName
java.lang.String getName()
Gets this plugin's name. This is typically the lowercase artifactId of the plugin.- Returns:
- Plugin's name.
-
getLogger
java.util.logging.Logger getLogger()
Gets the logger associated with this plugin.- Returns:
- Logger instance.
-
setEnabled
boolean setEnabled(boolean enabled) throws PluginException
Sets this artifact's enabled state.- Parameters:
enabled
- enabled state- Returns:
- true if the artifact's state was changed, false otherwise.
- Throws:
PluginException
-
isEnabled
boolean isEnabled()
Finds if this plugin is enabled.- Returns:
- true if the plugin is enabled, false otherwise.
-
-