|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bukkit.plugin.PluginBase org.bukkit.plugin.java.JavaPlugin
public abstract class JavaPlugin
Represents a Java plugin
Constructor Summary | |
---|---|
JavaPlugin()
|
Method Summary | |
---|---|
protected ClassLoader |
getClassLoader()
Returns the ClassLoader which holds this plugin |
PluginCommand |
getCommand(String name)
Gets the command with the given name, specific to this plugin. |
FileConfiguration |
getConfig()
Gets a FileConfiguration for this plugin, read through "config.yml" |
com.avaje.ebean.EbeanServer |
getDatabase()
Gets the EbeanServer tied to this plugin. |
List<Class<?>> |
getDatabaseClasses()
Provides a list of all classes that should be persisted in the database |
File |
getDataFolder()
Returns the folder that the plugin data's files are located in. |
ChunkGenerator |
getDefaultWorldGenerator(String worldName,
String id)
Gets a ChunkGenerator for use in a default world, as specified in the server configuration |
PluginDescriptionFile |
getDescription()
Returns the plugin.yaml file containing the details for this plugin |
protected File |
getFile()
Returns the file which contains this plugin |
Logger |
getLogger()
Returns the primary logger associated with this server instance. |
PluginLoader |
getPluginLoader()
Gets the associated PluginLoader responsible for this plugin |
InputStream |
getResource(String filename)
Gets an embedded resource in this plugin |
Server |
getServer()
Returns the Server instance currently running this plugin |
protected void |
initialize(PluginLoader loader,
Server server,
PluginDescriptionFile description,
File dataFolder,
File file,
ClassLoader classLoader)
Initializes this plugin with the given variables. |
protected void |
installDDL()
|
boolean |
isEnabled()
Returns a value indicating whether or not this plugin is currently enabled |
boolean |
isInitialized()
Gets the initialization status of this plugin |
boolean |
isNaggable()
Simple boolean if we can still nag to the logs about things |
boolean |
onCommand(CommandSender sender,
Command command,
String label,
String[] args)
Executes the given command, returning its success |
void |
onDisable()
Called when this plugin is disabled |
void |
onEnable()
Called when this plugin is enabled |
void |
onLoad()
Called after a plugin is loaded but before it has been enabled. |
List<String> |
onTabComplete(CommandSender sender,
Command command,
String alias,
String[] args)
Requests a list of possible completions for a command argument. |
void |
reloadConfig()
Discards any data in Plugin.getConfig() and reloads from disk. |
protected void |
removeDDL()
|
void |
saveConfig()
Saves the FileConfiguration retrievable by Plugin.getConfig() . |
void |
saveDefaultConfig()
Saves the raw contents of the default config.yml file to the location retrievable by Plugin.getConfig() . |
void |
saveResource(String resourcePath,
boolean replace)
Saves the raw contents of any resource embedded with a plugin's .jar file assuming it can be found using Plugin.getResource(String) . |
protected void |
setEnabled(boolean enabled)
Sets the enabled state of this plugin |
void |
setNaggable(boolean canNag)
Set naggable state |
String |
toString()
|
Methods inherited from class org.bukkit.plugin.PluginBase |
---|
equals, getName, hashCode |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JavaPlugin()
Method Detail |
---|
public final File getDataFolder()
public final PluginLoader getPluginLoader()
public final Server getServer()
public final boolean isEnabled()
protected File getFile()
public final PluginDescriptionFile getDescription()
public FileConfiguration getConfig()
Plugin
FileConfiguration
for this plugin, read through "config.yml"
If there is a default config.yml embedded in this plugin, it will be provided as a default for this Configuration.
public void reloadConfig()
Plugin
Plugin.getConfig()
and reloads from disk.
public void saveConfig()
Plugin
FileConfiguration
retrievable by Plugin.getConfig()
.
public void saveDefaultConfig()
Plugin
Plugin.getConfig()
.
If there is no default config.yml embedded in the plugin, an empty config.yml file is saved.
This should fail silently if the config.yml already exists.
public void saveResource(String resourcePath, boolean replace)
Plugin
Plugin.getResource(String)
. The resource is saved into the plugin's data folder using the same hierarchy
as the .jar file (subdirectories are preserved).
resourcePath
- the embedded resource path to look for within the plugin's .jar file. (No preceding slash).replace
- if true, the embedded resource will overwrite the contents of an existing file.public InputStream getResource(String filename)
Plugin
filename
- Filename of the resource
protected final ClassLoader getClassLoader()
protected final void setEnabled(boolean enabled)
enabled
- true if enabled, otherwise falseprotected final void initialize(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader)
This method should never be called manually.
loader
- PluginLoader that is responsible for this pluginserver
- Server instance that is running this plugindescription
- PluginDescriptionFile containing metadata on this plugindataFolder
- Folder containing the plugin's datafile
- File containing this pluginclassLoader
- ClassLoader which holds this pluginpublic List<Class<?>> getDatabaseClasses()
public final boolean isInitialized()
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
sender
- Source of the commandcommand
- Command which was executedlabel
- Alias of the command which was usedargs
- Passed command arguments
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args)
sender
- Source of the commandcommand
- Command which was executedalias
- The alias usedargs
- The arguments passed to the command, including final partial argument to be completed and command label
public PluginCommand getCommand(String name)
PluginDescriptionFile
to exist at runtime.
name
- name or alias of the command
public void onLoad()
Plugin
public void onDisable()
Plugin
public void onEnable()
Plugin
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
Plugin
ChunkGenerator
for use in a default world, as specified in the server configuration
worldName
- Name of the world that this will be applied toid
- Unique ID, if any, that was specified to indicate which generator was requested
public final boolean isNaggable()
Plugin
public final void setNaggable(boolean canNag)
Plugin
canNag
- is this plugin still naggable?public com.avaje.ebean.EbeanServer getDatabase()
Plugin
EbeanServer
tied to this plugin. This will only be
available if enabled in the PluginDescriptionFile.isDatabaseEnabled()
For more information on the use of Avaje Ebeans ORM, see Avaje Ebeans Documentation
For an example using Ebeans ORM, see Bukkit's Homebukkit Plugin
protected void installDDL()
protected void removeDDL()
public final Logger getLogger()
Plugin
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |