public final class PluginManager extends Object
Constructor and Description |
---|
PluginManager(ProxyServer proxy) |
PluginManager(ProxyServer proxy,
org.yaml.snakeyaml.Yaml yaml,
EventBus eventBus) |
Modifier and Type | Method and Description |
---|---|
<T extends Event> |
callEvent(T event)
Dispatch an event to all subscribed listeners and return the event once
it has been handled by these listeners.
|
void |
detectPlugins(File folder)
Load all plugins from the specified folder.
|
boolean |
dispatchCommand(CommandSender sender,
String commandLine) |
boolean |
dispatchCommand(CommandSender sender,
String commandLine,
List<String> tabResults)
Execute a command if it is registered, else return false.
|
void |
enablePlugins() |
Collection<Map.Entry<String,Command>> |
getCommands()
Get an unmodifiable collection of all registered commands.
|
Plugin |
getPlugin(String name)
Returns a loaded plugin identified by the specified name.
|
Collection<Plugin> |
getPlugins()
Returns the
Plugin objects corresponding to all loaded plugins. |
boolean |
isExecutableCommand(String commandName,
CommandSender sender)
Checks if the command is registered and can possibly be executed by the
sender (without taking permissions into account).
|
void |
loadPlugins() |
void |
registerCommand(Plugin plugin,
Command command)
Register a command so that it may be executed.
|
void |
registerListener(Plugin plugin,
Listener listener)
Register a
Listener for receiving called events. |
void |
unregisterCommand(Command command)
Unregister a command so it will no longer be executed.
|
void |
unregisterCommands(Plugin plugin)
Unregister all commands owned by a
Plugin |
void |
unregisterListener(Listener listener)
Unregister a
Listener so that the events do not reach it anymore. |
void |
unregisterListeners(Plugin plugin)
Unregister all of a Plugin's listener.
|
public PluginManager(ProxyServer proxy)
public PluginManager(ProxyServer proxy, org.yaml.snakeyaml.Yaml yaml, EventBus eventBus)
public void registerCommand(Plugin plugin, Command command)
plugin
- the plugin owning this commandcommand
- the command to registerpublic void unregisterCommand(Command command)
command
- the command to unregisterpublic void unregisterCommands(Plugin plugin)
Plugin
plugin
- the plugin to register the commands ofpublic boolean isExecutableCommand(String commandName, CommandSender sender)
commandName
- the name of the commandsender
- the sender executing the commandpublic boolean dispatchCommand(CommandSender sender, String commandLine)
public boolean dispatchCommand(CommandSender sender, String commandLine, List<String> tabResults)
sender
- the sender executing the commandcommandLine
- the complete command line including command name and
argumentstabResults
- list to place tab results into. If this list is non
null then the command will not be executed and tab results will be
returned instead.public Collection<Plugin> getPlugins()
Plugin
objects corresponding to all loaded plugins.public Plugin getPlugin(String name)
name
- of the plugin to retrievepublic void loadPlugins()
public void enablePlugins()
public void detectPlugins(File folder)
folder
- the folder to search for plugins inpublic <T extends Event> T callEvent(T event)
T
- the type bounds, must be a class which extends eventevent
- the event to callpublic void registerListener(Plugin plugin, Listener listener)
Listener
for receiving called events. Methods in this
Object which wish to receive events must be annotated with the
EventHandler
annotation.plugin
- the owning pluginlistener
- the listener to register events forpublic void unregisterListener(Listener listener)
Listener
so that the events do not reach it anymore.listener
- the listener to unregisterpublic void unregisterListeners(Plugin plugin)
plugin
- target pluginpublic Collection<Map.Entry<String,Command>> getCommands()
Copyright © 2012–2020 SpigotMC. All rights reserved.