public abstract class AbstractPlugin
extends java.lang.Object
init() in the constructor of your plugin. Otherwise it will not work!| Constructor and Description |
|---|
AbstractPlugin() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
java.nio.file.Path |
getAbsolutePath(java.lang.String... paths)
Gets the absolute path of the parameter.
|
java.lang.String |
getAbsolutePathString(java.lang.String... paths)
Gets the string version of
getAbsolutePath(String...), uses Path.toString(). |
abstract java.lang.String |
getAuthor()
Gets the name of the author.
Usage of String.intern() is recommend if you have multiple plugins under your name. |
PluginConditions |
getConditions()
Gets the plugin condition holder.
|
abstract java.lang.String |
getCreatedAt()
Gets the creation date of this plugin.
|
abstract java.lang.String |
getDescription()
Gets the plugin's description.
Feel free to provide some short details of your plugin. |
FileInstaller |
getFileInstaller()
Gets the file installer.
|
java.util.List<IPluginInstaller> |
getInstallers()
Gets a list of the plugin installers that implements
IPluginInstaller. |
PluginMigrations |
getMigrations()
Gets the plugin migrations storage.
|
abstract java.lang.String |
getName()
Gets the name of the plugin.
People often use Class.getSimpleName() but you are allowed to use your own naming also. |
int |
getPriority()
Gets plugin's priority.
|
java.nio.file.Path |
getRelativePath(java.lang.String... paths)
Gets the relative path of the given parameters.
|
java.lang.String |
getRelativePathString(java.lang.String... paths)
Gets the string version of
getRelativePath(String...), uses Path.toString(). |
PluginState |
getState()
Gets the actual state of the plugin.
|
abstract int |
getVersion()
Gets the actual version of this plugin.
|
int |
hashCode() |
protected void |
init()
A mandatory method that must be triggered in the constructor of your plugin.
Sets up the plugin's environment related things and changed the plugin's state from available to initialized. |
void |
install()
Installs your plugin or throws an exception.
|
void |
migrate(int from,
int to)
Migrates your plugin from an older version to another.
|
protected abstract void |
onInstall()
Triggered whenever you install your plugin.
|
protected abstract void |
onMigrate(int from,
int to)
Triggered whenever you migrate your plugin from a version to another.
|
protected abstract void |
onStart()
Triggered whenever your plugin starts.
|
void |
onStateChanged(PluginState oldState,
PluginState newState)
An event triggered whenever the plugin's state is changed.
|
protected abstract void |
onStop()
Triggered whenever your plugin stops.
|
protected abstract void |
onUninstall()
Triggered whenever you uninstall your plugin.
|
protected boolean |
setState(PluginState currentState,
PluginState newState)
Sets the state of the plugin.
|
protected abstract void |
setup(FileInstaller fileInstaller,
PluginMigrations migrations,
PluginConditions pluginConditions)
Triggered whenever the plugin is being initialized.
|
void |
start()
Starts your plugin or throws an exception.
|
void |
stop()
Stops your plugin or throws an exception.
|
void |
uninstall()
Uninstalls your plugin or throws an exception.
|
public abstract java.lang.String getName()
Class.getSimpleName() but you are allowed to use your own naming also.public abstract java.lang.String getAuthor()
String.intern() is recommend if you have multiple plugins under your name.public abstract java.lang.String getCreatedAt()
public abstract java.lang.String getDescription()
public abstract int getVersion()
protected abstract void setup(FileInstaller fileInstaller, PluginMigrations migrations, PluginConditions pluginConditions)
fileInstaller - the file installermigrations - the relevant plugin migrationspluginConditions - plugin conditionsprotected abstract void onInstall()
protected abstract void onUninstall()
protected abstract void onMigrate(int from,
int to)
from - previous releaseto - actual releaseprotected abstract void onStart()
protected abstract void onStop()
protected final boolean setState(PluginState currentState, PluginState newState)
currentState - state fromnewState - state totrue when the state is changed, otherwise falsepublic final PluginState getState()
public void onStateChanged(PluginState oldState, PluginState newState)
oldState - the previous statenewState - the actual stateprotected final void init()
public final void start()
throws PluginException
PluginExceptionpublic final void stop()
throws PluginException
PluginExceptionpublic final void install()
throws PluginException
PluginExceptionpublic final void uninstall()
throws PluginException
PluginExceptionpublic final void migrate(int from,
int to)
throws PluginException
from - the older versionto - the actual (newer) versionPluginExceptionpublic final PluginConditions getConditions()
public final FileInstaller getFileInstaller()
public java.util.List<IPluginInstaller> getInstallers()
IPluginInstaller.public final PluginMigrations getMigrations()
public final java.nio.file.Path getAbsolutePath(java.lang.String... paths)
paths - path parameters given by the userpublic final java.lang.String getAbsolutePathString(java.lang.String... paths)
getAbsolutePath(String...), uses Path.toString().paths - public final java.nio.file.Path getRelativePath(java.lang.String... paths)
paths - path parameters given by the userpublic final java.lang.String getRelativePathString(java.lang.String... paths)
getRelativePath(String...), uses Path.toString().paths - path given by the userpublic int getPriority()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object