@NotThreadSafe public class Plugin extends Object
Modifier and Type | Field and Description |
---|---|
PluginLoader |
classLoader |
Modifier | Constructor and Description |
---|---|
protected |
Plugin() |
Modifier and Type | Method and Description |
---|---|
<T extends Command> |
commandBy(Class<T> c)
Obtains the command instance with the class specified
|
File |
configDirectory()
The plugin directory
|
Config |
defaultConfig()
The default configuration for this plugin, which may or may not exist physically
|
PluginDesc |
description()
Obtains the annotation given by this plugin
|
void |
disable()
Called by the handler to indicate the disabling of this plugin
|
void |
enable()
Called by the handler to indicate the enabling of this plugin
|
boolean |
equals(Object other) |
int |
hashCode() |
void |
init(File pluginFile,
PluginDesc description,
PluginLoader loader) |
static Plugin |
instance()
Obtains the instance of the plugin which the caller class is in
|
static <T extends Plugin> |
instance(Class<T> c)
Obtains the instance of the plugin which has the specified class
|
<T extends Listener> |
listenerBy(Class<T> c)
Obtains the listener instance with the class specified
|
void |
load()
Called by the handler to indicate the plugin has been constructed
|
org.slf4j.Logger |
logger()
Gets the logger for this plugin
|
File |
pluginFile()
Obtains the file which this plugin was loaded from
|
void |
saveDefaultConfig()
Saves the configuration inside the jar to the plugin directory
|
void |
saveResource(String name,
boolean replace)
Saves a resource inside the jar to the plugin directory
|
public PluginLoader classLoader
protected Plugin()
public void init(File pluginFile, PluginDesc description, PluginLoader loader)
@Nullable public static Plugin instance()
Returns null
if the plugin has not been loaded yet, or if the class is not a plugin loaded on the
server.
@Nullable public static <T extends Plugin> T instance(Class<T> c)
Returns null
if the plugin has not been loaded yet, or if the class is not a plugin loaded on the
server.
c
- the main class of the plugin to obtain the instance ofpublic void load()
public void enable()
public void disable()
public <T extends Listener> T listenerBy(Class<T> c)
c
- the class to find the listener instance bypublic <T extends Command> T commandBy(Class<T> c)
c
- the class to find the command instance bypublic org.slf4j.Logger logger()
public void saveDefaultConfig()
If the configuration is already saved, this does not overwrite it.
public void saveResource(String name, boolean replace)
name
- the filename of the directoryreplace
- whether or not replace the old resource, if it existspublic final File pluginFile()
public Config defaultConfig()
public File configDirectory()
The returned file includes the trailing file separator
@Nonnull public final PluginDesc description()
Copyright © 2016. All rights reserved.