public class PluginUtils
extends java.lang.Object
| Constructor and Description |
|---|
PluginUtils() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
disablePlugin(org.bukkit.plugin.Plugin plugin)
Disable a
Plugin by its instance |
boolean |
disablePlugin(java.lang.String name)
Disable a
Plugin by its name |
boolean |
enablePlugin(org.bukkit.plugin.Plugin plugin)
Enable a
Plugin by its instance |
boolean |
enablePlugin(java.lang.String name)
Enable a
Plugin by its name |
java.util.List<java.lang.String> |
getCommands(org.bukkit.plugin.Plugin plugin)
Get a
List of all commands registered by PluginsThis only works if they are registered as PluginCommandsAnything using events or other methods to handle commands will not work |
java.util.Optional<org.bukkit.plugin.Plugin> |
getPlugin(java.lang.String name)
Get a
Plugin instance by its name |
org.bukkit.plugin.PluginDescriptionFile |
getPluginDescription(java.io.File file)
Get the
PluginDescriptionFile of a plugin jar |
java.util.Optional<java.io.File> |
getPluginFile(org.bukkit.plugin.Plugin plugin)
Get the
File of the Plugin jarThis tries calling the JavaPlugin.getFile() method firstIf that fails, all PluginDescriptionFiles are searched for the name of the Plugin |
org.bukkit.plugin.PluginManager |
getPluginManager()
Get the
PluginManager instance of the server |
org.bukkit.plugin.Plugin[] |
getPlugins()
Get an array of all loaded
Plugins |
java.util.List<org.bukkit.plugin.Plugin> |
getPluginsByLoadOrder()
Get a
List of all Plugins sorted by their dependenciesLoading all Plugins in the correct order is important for the correct functioning of the Plugins |
java.io.File |
getPluginsDirectory()
Get the
plugins directory |
java.io.File |
getUpdateDirectory()
Get the update directory for plugins
|
boolean |
isPluginEnabled(java.lang.String name)
Check if a
Plugin is enabled by its name |
boolean |
isPluginLoaded(java.lang.String name)
Check if a
Plugin is loaded by its name |
org.bukkit.plugin.Plugin |
loadPlugin(org.bukkit.plugin.Plugin plugin)
|
org.bukkit.plugin.Plugin |
loadPlugin(java.lang.String name)
Load a
Plugin by its nameThis tries to get the Plugin File by name
and if not found scans all PluginDescriptionFiles for the name |
void |
reloadConfig(org.bukkit.plugin.Plugin plugin)
Reload the config of a
Plugin by its instance |
void |
reloadConfig(java.lang.String name)
Reload the config of a
Plugin by its name |
org.bukkit.plugin.Plugin |
reloadPlugin(org.bukkit.plugin.Plugin plugin)
Reload a
Plugin by its nameThis first unloads the Plugin and then loads it again |
void |
unloadPlugin(org.bukkit.plugin.Plugin plugin)
Unload a
Plugin by its instanceThis closes the URLClassLoader of the Plugin which causes
the Plugin no longer being able to load new Classes |
void |
unloadPlugin(java.lang.String name)
|
boolean |
updatePlugin(java.io.File pluginFile)
Update a
Plugin from the updates folder |
public java.io.File getPluginsDirectory()
plugins directoryFilepublic java.io.File getUpdateDirectory()
Filepublic org.bukkit.plugin.PluginManager getPluginManager()
PluginManager instance of the serverPluginManager instancepublic org.bukkit.plugin.PluginDescriptionFile getPluginDescription(java.io.File file)
throws org.bukkit.plugin.InvalidDescriptionException
PluginDescriptionFile of a plugin jarfile - The plugin jarPluginDescriptionFileorg.bukkit.plugin.InvalidDescriptionException - If the plugin.yml is invalidpublic org.bukkit.plugin.Plugin[] getPlugins()
PluginsPluginspublic java.util.Optional<org.bukkit.plugin.Plugin> getPlugin(java.lang.String name)
Plugin instance by its namename - The name of the PluginPlugin instance or Optional.empty() if not foundpublic boolean isPluginLoaded(java.lang.String name)
Plugin is loaded by its namename - The name of the Plugintrue if the Plugin is loadedpublic boolean isPluginEnabled(java.lang.String name)
Plugin is enabled by its namename - The name of the Plugintrue if the Plugin is enabledpublic boolean enablePlugin(java.lang.String name)
Plugin by its namename - The name of the Plugintrue if the Plugin was enabled successfullypublic boolean enablePlugin(org.bukkit.plugin.Plugin plugin)
Plugin by its instanceplugin - The Plugin instancetrue if the Plugin was enabled successfullypublic boolean disablePlugin(java.lang.String name)
Plugin by its namename - The name of the Plugintrue if the Plugin was disabled successfullypublic boolean disablePlugin(org.bukkit.plugin.Plugin plugin)
Plugin by its instanceplugin - The Plugin instancetrue if the Plugin was disabled successfullypublic void reloadConfig(java.lang.String name)
Plugin by its namename - The name of the Pluginpublic void reloadConfig(org.bukkit.plugin.Plugin plugin)
Plugin by its instanceplugin - The Plugin instancepublic org.bukkit.plugin.Plugin reloadPlugin(org.bukkit.plugin.Plugin plugin)
Plugin by its namePlugin and then loads it againplugin - The Plugin instancePlugin instancejava.lang.IllegalStateException - If anything goes wrongpublic org.bukkit.plugin.Plugin loadPlugin(org.bukkit.plugin.Plugin plugin)
plugin - The Plugin instancePlugin instancejava.lang.IllegalStateException - If anything goes wrongpublic org.bukkit.plugin.Plugin loadPlugin(java.lang.String name)
Plugin by its namePlugin File by name
and if not found scans all PluginDescriptionFiles for the namename - The name of the PluginPlugin instancejava.lang.IllegalStateException - If anything goes wrongpublic void unloadPlugin(java.lang.String name)
name - The name of the Pluginjava.lang.IllegalStateException - If anything goes wrongpublic void unloadPlugin(org.bukkit.plugin.Plugin plugin)
Plugin by its instanceURLClassLoader of the Plugin which causes
the Plugin no longer being able to load new Classesplugin - The Plugin instancejava.lang.IllegalStateException - If anything goes wrongpublic java.util.List<org.bukkit.plugin.Plugin> getPluginsByLoadOrder()
List of all Plugins sorted by their dependenciesPlugins in the correct order is important for the correct functioning of the PluginsListpublic java.util.List<java.lang.String> getCommands(org.bukkit.plugin.Plugin plugin)
List of all commands registered by PluginsPluginCommandsplugin - The instance of the PluginListpublic java.util.Optional<java.io.File> getPluginFile(org.bukkit.plugin.Plugin plugin)
File of the Plugin jarJavaPlugin.getFile() method firstPluginDescriptionFiles are searched for the name of the Pluginplugin - The instance of the PluginFile of the Plugin jar or Optional.empty() if not foundpublic boolean updatePlugin(java.io.File pluginFile)
Plugin from the updates folderpluginFile - The File of the Plugintrue if the update was successful