Bukkit  1.7.9-R0.2-63-gcb87f4e
 All Classes Namespaces Files Functions Variables Enumerator Pages
org.bukkit.plugin.java.JavaPlugin Class Reference

Represents a Java plugin. More...

+ Inheritance diagram for org.bukkit.plugin.java.JavaPlugin:
+ Collaboration diagram for org.bukkit.plugin.java.JavaPlugin:

Public Member Functions

 JavaPlugin ()
 
final File getDataFolder ()
 Returns the folder that the plugin data's files are located in.
 
final PluginLoader getPluginLoader ()
 Gets the associated PluginLoader responsible for this plugin.
 
final Server getServer ()
 Returns the Server instance currently running this plugin.
 
final boolean isEnabled ()
 Returns a value indicating whether or not this plugin is currently enabled.
 
final PluginDescriptionFile getDescription ()
 Returns the plugin.yaml file containing the details for this plugin.
 
FileConfiguration getConfig ()
 
void reloadConfig ()
 
void saveConfig ()
 
void saveDefaultConfig ()
 
void saveResource (String resourcePath, boolean replace)
 
InputStream getResource (String filename)
 
List< Class<?> > getDatabaseClasses ()
 Provides a list of all classes that should be persisted in the database.
 
final boolean isInitialized ()
 Gets the initialization status of this plugin.
 
boolean onCommand (CommandSender sender, Command command, String label, String[] args)
 
 
List< String > onTabComplete (CommandSender sender, Command command, String alias, String[] args)
 
 
PluginCommand getCommand (String name)
 Gets the command with the given name, specific to this plugin.
 
void onLoad ()
 
void onDisable ()
 
void onEnable ()
 
ChunkGenerator getDefaultWorldGenerator (String worldName, String id)
 
final boolean isNaggable ()
 
final void setNaggable (boolean canNag)
 
EbeanServer getDatabase ()
 
final Logger getLogger ()
 
String toString ()
 
- Public Member Functions inherited from org.bukkit.plugin.PluginBase
final int hashCode ()
 
final boolean equals (Object obj)
 
final String getName ()
 
- Public Member Functions inherited from org.bukkit.plugin.Plugin
File getDataFolder ()
 Returns the folder that the plugin data's files are located in.
 
PluginDescriptionFile getDescription ()
 Returns the plugin.yaml file containing the details for this plugin.
 
FileConfiguration getConfig ()
 Gets a FileConfiguration for this plugin, read through "config.yml".
 
InputStream getResource (String filename)
 Gets an embedded resource in this plugin.
 
void saveConfig ()
 Saves the FileConfiguration retrievable by getConfig().
 
void saveDefaultConfig ()
 Saves the raw contents of the default config.yml file to the location retrievable by 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 getResource(String).
 
void reloadConfig ()
 Discards any data in getConfig() and reloads from disk.
 
PluginLoader getPluginLoader ()
 Gets the associated PluginLoader responsible for this plugin.
 
Server getServer ()
 Returns the Server instance currently running this plugin.
 
boolean isEnabled ()
 Returns a value indicating whether or not this plugin is currently enabled.
 
void onDisable ()
 Called when this plugin is disabled.
 
void onLoad ()
 Called after a plugin is loaded but before it has been enabled.
 
void onEnable ()
 Called when this plugin is enabled.
 
boolean isNaggable ()
 Simple boolean if we can still nag to the logs about things.
 
void setNaggable (boolean canNag)
 Set naggable state.
 
EbeanServer getDatabase ()
 Gets the EbeanServer tied to this plugin.
 
ChunkGenerator getDefaultWorldGenerator (String worldName, String id)
 Gets a ChunkGenerator for use in a default world, as specified in the server configuration.
 
Logger getLogger ()
 Returns the plugin logger associated with this server's logger.
 
String getName ()
 Returns the name of the plugin.
 

Static Public Member Functions

static< TextendsJavaPlugin > T getPlugin (Class< T > clazz)
 This method provides fast access to the plugin that has provided the given plugin class, which is usually the plugin that implemented it.
 
static JavaPlugin getProvidingPlugin (Class<?> clazz)
 This method provides fast access to the plugin that has provided the given class.
 

Protected Member Functions

 JavaPlugin (final PluginLoader loader, final Server server, final PluginDescriptionFile description, final File dataFolder, final File file)
 
 JavaPlugin (final JavaPluginLoader loader, final PluginDescriptionFile description, final File dataFolder, final File file)
 
File getFile ()
 Returns the file which contains this plugin.
 
final Reader getTextResource (String file)
 Provides a reader for a text file located inside the jar.
 
final ClassLoader getClassLoader ()
 Returns the ClassLoader which holds this plugin.
 
final void setEnabled (final boolean enabled)
 Sets the enabled state of this plugin.
 
final void initialize (PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader)
 
void installDDL ()
 
void removeDDL ()
 

Detailed Description

Represents a Java plugin.

Definition at line 47 of file JavaPlugin.java.

Constructor & Destructor Documentation

org.bukkit.plugin.java.JavaPlugin.JavaPlugin ( )

Definition at line 61 of file JavaPlugin.java.

org.bukkit.plugin.java.JavaPlugin.JavaPlugin ( final PluginLoader  loader,
final Server  server,
final PluginDescriptionFile  description,
final File  dataFolder,
final File  file 
)
protected
Deprecated:
This method is intended for unit testing purposes when the other JavaPlugin(JavaPluginLoader, PluginDescriptionFile, File, File) constructor} cannot be used.

Its existence may be temporary.

Definition at line 77 of file JavaPlugin.java.

org.bukkit.plugin.java.JavaPlugin.JavaPlugin ( final JavaPluginLoader  loader,
final PluginDescriptionFile  description,
final File  dataFolder,
final File  file 
)
protected

Definition at line 85 of file JavaPlugin.java.

Member Function Documentation

final ClassLoader org.bukkit.plugin.java.JavaPlugin.getClassLoader ( )
protected
PluginCommand org.bukkit.plugin.java.JavaPlugin.getCommand ( String  name)

Gets the command with the given name, specific to this plugin.

Commands need to be registered in the PluginDescriptionFile to exist at runtime.

Parameters
namename or alias of the command
Returns
the plugin command if found, otherwise null

Definition at line 418 of file JavaPlugin.java.

References org.bukkit.plugin.PluginDescriptionFile.getName(), org.bukkit.command.PluginCommand.getPlugin(), org.bukkit.Server.getPluginCommand(), and org.bukkit.plugin.java.JavaPlugin.getServer().

FileConfiguration org.bukkit.plugin.java.JavaPlugin.getConfig ( )
EbeanServer org.bukkit.plugin.java.JavaPlugin.getDatabase ( )
List<Class<?> > org.bukkit.plugin.java.JavaPlugin.getDatabaseClasses ( )

Provides a list of all classes that should be persisted in the database.

Returns
List of Classes that are Ebeans

Definition at line 372 of file JavaPlugin.java.

final File org.bukkit.plugin.java.JavaPlugin.getDataFolder ( )

Returns the folder that the plugin data's files are located in.

The folder may not yet exist.

Returns
The folder.

Definition at line 100 of file JavaPlugin.java.

ChunkGenerator org.bukkit.plugin.java.JavaPlugin.getDefaultWorldGenerator ( String  worldName,
String  id 
)

Definition at line 443 of file JavaPlugin.java.

final PluginDescriptionFile org.bukkit.plugin.java.JavaPlugin.getDescription ( )

Returns the plugin.yaml file containing the details for this plugin.

Returns
Contents of the plugin.yaml file

Definition at line 150 of file JavaPlugin.java.

Referenced by org.bukkit.plugin.java.JavaPluginLoader.disablePlugin(), and org.bukkit.plugin.java.JavaPluginLoader.enablePlugin().

File org.bukkit.plugin.java.JavaPlugin.getFile ( )
protected

Returns the file which contains this plugin.

Returns
File containing this plugin

Definition at line 140 of file JavaPlugin.java.

final Logger org.bukkit.plugin.java.JavaPlugin.getLogger ( )
static <TextendsJavaPlugin> T org.bukkit.plugin.java.JavaPlugin.getPlugin ( Class< T >  clazz)
static

This method provides fast access to the plugin that has provided the given plugin class, which is usually the plugin that implemented it.

An exception to this would be if plugin's jar that contained the class does not extend the class, where the intended plugin would have resided in a different jar / classloader.

Parameters
clazzthe class desired
Returns
the plugin that provides and implements said class
Exceptions
IllegalArgumentExceptionif clazz is null
IllegalArgumentExceptionif clazz does not extend JavaPlugin
IllegalStateExceptionif clazz was not provided by a plugin, for example, if called with JavaPlugin.getPlugin(JavaPlugin.class)
IllegalStateExceptionif called from the static initializer for given JavaPlugin
ClassCastExceptionif plugin that provided the class does not extend the class

Definition at line 508 of file JavaPlugin.java.

final PluginLoader org.bukkit.plugin.java.JavaPlugin.getPluginLoader ( )

Gets the associated PluginLoader responsible for this plugin.

Returns
PluginLoader that controls this plugin

Definition at line 110 of file JavaPlugin.java.

static JavaPlugin org.bukkit.plugin.java.JavaPlugin.getProvidingPlugin ( Class<?>  clazz)
static

This method provides fast access to the plugin that has provided the given class.

Exceptions
IllegalArgumentExceptionif the class is not provided by a JavaPlugin
IllegalArgumentExceptionif class is null
IllegalStateExceptionif called from the static initializer for given JavaPlugin

Definition at line 534 of file JavaPlugin.java.

References org.bukkit.plugin.java.JavaPlugin.getClassLoader().

InputStream org.bukkit.plugin.java.JavaPlugin.getResource ( String  filename)
final Server org.bukkit.plugin.java.JavaPlugin.getServer ( )

Returns the Server instance currently running this plugin.

Returns
Server running this plugin

Definition at line 120 of file JavaPlugin.java.

Referenced by org.bukkit.plugin.java.JavaPlugin.getCommand().

final Reader org.bukkit.plugin.java.JavaPlugin.getTextResource ( String  file)
protected

Provides a reader for a text file located inside the jar.

The behavior of this method adheres to PluginAwareness.Flags#UTF8, or if not defined, uses UTF8 if FileConfiguration#UTF8_OVERRIDE is specified, or system default otherwise.

Parameters
filethe filename of the resource to load
Returns
null if getResource(String) returns null
Exceptions
IllegalArgumentExceptionif file is null
See Also
ClassLoader::getResourceAsStream(String)

Definition at line 174 of file JavaPlugin.java.

References org.bukkit.plugin.java.JavaPlugin.getResource(), and org.bukkit.configuration.file.FileConfiguration.UTF8_OVERRIDE.

final void org.bukkit.plugin.java.JavaPlugin.initialize ( PluginLoader  loader,
Server  server,
PluginDescriptionFile  description,
File  dataFolder,
File  file,
ClassLoader  classLoader 
)
protected
Deprecated:
This method is legacy and will be removed - it must be replaced by the specially provided constructor(s).

Definition at line 328 of file JavaPlugin.java.

References org.bukkit.Warning.WarningState.DEFAULT, org.bukkit.plugin.java.JavaPlugin.getLogger(), org.bukkit.plugin.PluginBase.getName(), org.bukkit.Server.getWarningState(), and org.bukkit.Warning.WarningState.OFF.

void org.bukkit.plugin.java.JavaPlugin.installDDL ( )
protected

Definition at line 462 of file JavaPlugin.java.

References org.bukkit.plugin.java.JavaPlugin.getDatabase().

final boolean org.bukkit.plugin.java.JavaPlugin.isEnabled ( )

Returns a value indicating whether or not this plugin is currently enabled.

Returns
true if this plugin is enabled, otherwise false

Definition at line 131 of file JavaPlugin.java.

Referenced by org.bukkit.plugin.java.JavaPlugin.setEnabled().

final boolean org.bukkit.plugin.java.JavaPlugin.isInitialized ( )

Gets the initialization status of this plugin.

Returns
true if this plugin is initialized, otherwise false
Deprecated:
This method cannot return false, as JavaPlugin is now initialized in the constructor.

Definition at line 390 of file JavaPlugin.java.

final boolean org.bukkit.plugin.java.JavaPlugin.isNaggable ( )

Definition at line 448 of file JavaPlugin.java.

boolean org.bukkit.plugin.java.JavaPlugin.onCommand ( CommandSender  sender,
Command  command,
String  label,
String[]  args 
)

Definition at line 398 of file JavaPlugin.java.

void org.bukkit.plugin.java.JavaPlugin.onDisable ( )

Definition at line 437 of file JavaPlugin.java.

Referenced by org.bukkit.plugin.java.JavaPlugin.setEnabled().

void org.bukkit.plugin.java.JavaPlugin.onEnable ( )

Definition at line 440 of file JavaPlugin.java.

Referenced by org.bukkit.plugin.java.JavaPlugin.setEnabled().

void org.bukkit.plugin.java.JavaPlugin.onLoad ( )

Definition at line 434 of file JavaPlugin.java.

List<String> org.bukkit.plugin.java.JavaPlugin.onTabComplete ( CommandSender  sender,
Command  command,
String  alias,
String[]  args 
)

Definition at line 406 of file JavaPlugin.java.

void org.bukkit.plugin.java.JavaPlugin.removeDDL ( )
protected

Definition at line 469 of file JavaPlugin.java.

References org.bukkit.plugin.java.JavaPlugin.getDatabase().

void org.bukkit.plugin.java.JavaPlugin.saveConfig ( )
void org.bukkit.plugin.java.JavaPlugin.saveDefaultConfig ( )

Definition at line 232 of file JavaPlugin.java.

References org.bukkit.plugin.java.JavaPlugin.saveResource().

void org.bukkit.plugin.java.JavaPlugin.saveResource ( String  resourcePath,
boolean  replace 
)
final void org.bukkit.plugin.java.JavaPlugin.setEnabled ( final boolean  enabled)
protected
final void org.bukkit.plugin.java.JavaPlugin.setNaggable ( boolean  canNag)

Definition at line 453 of file JavaPlugin.java.

String org.bukkit.plugin.java.JavaPlugin.toString ( )

The documentation for this class was generated from the following file: