Package org.bukkit.plugin
Interface Plugin
- All Superinterfaces:
CommandExecutor
,LifecycleEventOwner
,TabCompleter
,TabExecutor
- All Known Implementing Classes:
JavaPlugin
,PluginBase
Represents a Plugin
The use of PluginBase
is recommended for actual Implementation
-
Method Summary
Modifier and TypeMethodDescriptiondefault ComponentLogger
Gets aFileConfiguration
for this plugin, read through "config.yml"Returns the folder that the plugin data files are located in.default Path
Returns the path that the plugin data files are located in.getDefaultBiomeProvider
(@NotNull String worldName, @Nullable String id) Gets aBiomeProvider
for use in a default world, as specified in the server configurationgetDefaultWorldGenerator
(@NotNull String worldName, @Nullable String id) Gets aChunkGenerator
for use in a default world, as specified in the server configurationDeprecated.May be inaccurate due to different plugin implementations.Get the lifecycle event manager for registering handlers for lifecycle events allowed on thePlugin
.default Logger
Deprecated.usegetSLF4JLogger()
Returns the plugin logger associated with this server's logger.getName()
Returns the name of the plugin.Deprecated, for removal: This API element is subject to removal in a future version.Gets the plugin meta for this plugin.getResource
(@NotNull String filename) Gets an embedded resource in this pluginReturns the Server instance currently running this plugindefault Logger
boolean
Returns a value indicating whether or not this plugin is currently enabledboolean
Simple boolean if we can still nag to the logs about thingsvoid
Called when this plugin is disabledvoid
onEnable()
Called when this plugin is enabledvoid
onLoad()
Called after a plugin is loaded but before it has been enabled.void
Discards any data ingetConfig()
and reloads from disk.void
Saves theFileConfiguration
retrievable bygetConfig()
.void
Saves the raw contents of the default config.yml file to the location retrievable bygetConfig()
.void
saveResource
(@NotNull String resourcePath, boolean replace) Saves the raw contents of any resource embedded with a plugin's .jar file assuming it can be found usinggetResource(String)
.void
setNaggable
(boolean canNag) Set naggable stateMethods inherited from interface org.bukkit.command.CommandExecutor
onCommand
Methods inherited from interface org.bukkit.command.TabCompleter
onTabComplete
-
Method Details
-
getDataFolder
Returns the folder that the plugin data files are located in. The folder may not yet exist.- Returns:
- The folder
-
getDataPath
Returns the path that the plugin data files are located in. The folder may not yet exist.- Returns:
- The folder
- See Also:
-
getDescription
Deprecated.May be inaccurate due to different plugin implementations.Returns the plugin.yml file containing the details for this plugin- Returns:
- Contents of the plugin.yml file
- See Also:
-
getPluginMeta
Gets the plugin meta for this plugin.- Specified by:
getPluginMeta
in interfaceLifecycleEventOwner
- Returns:
- configuration
-
getConfig
Gets aFileConfiguration
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.
- Returns:
- Plugin configuration
-
getResource
Gets an embedded resource in this plugin- Parameters:
filename
- Filename of the resource- Returns:
- File if found, otherwise null
-
saveConfig
void saveConfig()Saves theFileConfiguration
retrievable bygetConfig()
. -
saveDefaultConfig
void saveDefaultConfig()Saves the raw contents of the default config.yml file to the location retrievable bygetConfig()
.This should fail silently if the config.yml already exists.
-
saveResource
Saves the raw contents of any resource embedded with a plugin's .jar file assuming it can be found usinggetResource(String)
.The resource is saved into the plugin's data folder using the same hierarchy as the .jar file (subdirectories are preserved).
- Parameters:
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.- Throws:
IllegalArgumentException
- if the resource path is null, empty, or points to a nonexistent resource.
-
reloadConfig
void reloadConfig()Discards any data ingetConfig()
and reloads from disk. -
getPluginLoader
Deprecated, for removal: This API element is subject to removal in a future version.Gets the associated PluginLoader responsible for this plugin- Returns:
- PluginLoader that controls this plugin
-
getServer
Returns the Server instance currently running this plugin- Returns:
- Server running this plugin
-
isEnabled
boolean isEnabled()Returns a value indicating whether or not this plugin is currently enabled- Returns:
- true if this plugin is enabled, otherwise false
-
onDisable
void onDisable()Called when this plugin is disabled -
onLoad
void onLoad()Called after a plugin is loaded but before it has been enabled.When multiple plugins are loaded, the onLoad() for all plugins is called before any onEnable() is called.
-
onEnable
void onEnable()Called when this plugin is enabled -
isNaggable
boolean isNaggable()Simple boolean if we can still nag to the logs about things- Returns:
- boolean whether we can nag
-
setNaggable
void setNaggable(boolean canNag) Set naggable state- Parameters:
canNag
- is this plugin still naggable?
-
getDefaultWorldGenerator
@Nullable @Nullable ChunkGenerator getDefaultWorldGenerator(@NotNull @NotNull String worldName, @Nullable @Nullable String id) Gets aChunkGenerator
for use in a default world, as specified in the server configuration- Parameters:
worldName
- Name of the world that this will be applied toid
- Unique ID, if any, that was specified to indicate which generator was requested- Returns:
- ChunkGenerator for use in the default world generation
-
getDefaultBiomeProvider
@Nullable @Nullable BiomeProvider getDefaultBiomeProvider(@NotNull @NotNull String worldName, @Nullable @Nullable String id) Gets aBiomeProvider
for use in a default world, as specified in the server configuration- Parameters:
worldName
- Name of the world that this will be applied toid
- Unique ID, if any, that was specified to indicate which biome provider was requested- Returns:
- BiomeProvider for use in the default world generation
-
getLogger
Returns the plugin logger associated with this server's logger. The returned logger automatically tags all log messages with the plugin's name.- Returns:
- Logger associated with this plugin
-
getComponentLogger
-
getSLF4JLogger
-
getLog4JLogger
Deprecated.usegetSLF4JLogger()
-
getName
Returns the name of the plugin.This should return the bare name of the plugin and should be used for comparison.
- Returns:
- name of the plugin
-
getLifecycleManager
@NotNull LifecycleEventManager<Plugin> getLifecycleManager()Get the lifecycle event manager for registering handlers for lifecycle events allowed on thePlugin
.- Returns:
- the lifecycle event manager
-