Package net.md_5.bungee.api.plugin
Class PluginManager
java.lang.Object
net.md_5.bungee.api.plugin.PluginManager
Class to manage bridging between plugin duties and implementation duties, for
example event handling and plugin management.
-
Constructor Summary
ConstructorsConstructorDescriptionPluginManager(ProxyServer proxy, MethodHandles.Lookup lookup, Consumer<Object> additionalEventListenerRegistration) PluginManager(ProxyServer proxy, org.yaml.snakeyaml.Yaml yaml, EventBus eventBus, net.md_5.bungee.api.plugin.LibraryLoader libraryLoader, CommandDispatcherProxy commandDispatcher, MethodHandles.Lookup lookup, Consumer<Object> additionalEventListenerRegistration) -
Method Summary
Modifier and TypeMethodDescription<T extends Event>
TcallEvent(T event) Dispatch an event to all subscribed listeners and return the event once it has been handled by these listeners.voiddetectPlugins(File folder) Load all plugins from the specified folder.voiddisablePlugin(String pluginName) voiddisablePlugin(Plugin plugin) Disables the specified plugin, if it is enabled.booleandispatchCommand(CommandSender sender, String commandLine) booleandispatchCommand(CommandSender sender, String commandLine, List<String> tabResults) Execute a command if it is registered, else return false.voidCompletableFuture<com.mojang.brigadier.suggestion.Suggestions>getBrigadierCompletions(CommandSender sender, String commandLine) getCommand(String name) Deprecated.internal use only in order to support waterfall's ProxyDefineCommandsEventGet an unmodifiable collection of all registered commands.Collection<com.mojang.brigadier.tree.CommandNode<CommandSender>>Gets all registered commands as brigadier commands.Returns a loaded plugin identified by the specified name.Returns thePluginobjects corresponding to all loaded plugins.booleanisExecutableCommand(String commandName, CommandSender sender) Checks if the command is registered and can possibly be executed by the sender (without taking permissions into account).booleanisPluginEnabled(String pluginName) booleanisPluginEnabled(Plugin plugin) Returns whenever a plugin is enabledvoidvoidregisterCommand(BrigadierCommand command) voidregisterCommand(Plugin plugin, Command command) Register a command so that it may be executed.voidregisterListener(Plugin plugin, Listener listener) Register aListenerfor receiving called events.tabCompleteCommand(CommandSender sender, String commandLine) Searches for tab-complete suggestions for the given command line.voidunregisterCommand(BrigadierCommand command) voidunregisterCommand(Command command) Unregister a command so it will no longer be executed.voidunregisterCommands(Plugin plugin) Unregister all commands owned by aPluginvoidunregisterListener(Listener listener) Unregister aListenerso that the events do not reach it anymore.voidunregisterListeners(Plugin plugin) Unregister all of a Plugin's listener.
-
Constructor Details
-
PluginManager
public PluginManager(ProxyServer proxy, MethodHandles.Lookup lookup, Consumer<Object> additionalEventListenerRegistration) -
PluginManager
public PluginManager(ProxyServer proxy, org.yaml.snakeyaml.Yaml yaml, EventBus eventBus, net.md_5.bungee.api.plugin.LibraryLoader libraryLoader, CommandDispatcherProxy commandDispatcher, MethodHandles.Lookup lookup, Consumer<Object> additionalEventListenerRegistration)
-
-
Method Details
-
registerCommand
Register a command so that it may be executed.- Parameters:
plugin- the plugin owning this commandcommand- the command to register
-
registerCommand
-
unregisterCommand
-
unregisterCommand
Unregister a command so it will no longer be executed.- Parameters:
command- the command to unregister
-
unregisterCommands
Unregister all commands owned by aPlugin- Parameters:
plugin- the plugin to register the commands of
-
isExecutableCommand
Checks if the command is registered and can possibly be executed by the sender (without taking permissions into account).- Parameters:
commandName- the name of the commandsender- the sender executing the command- Returns:
- whether the command will be handled
-
getCommand
Deprecated.internal use only in order to support waterfall's ProxyDefineCommandsEventRetrieves command in a legacy form by the name/alias specified.- Parameters:
name- command name/alias- Returns:
- command or null
-
dispatchCommand
-
dispatchCommand
Execute a command if it is registered, else return false.- Parameters:
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.- Returns:
- whether the command was handled
-
tabCompleteCommand
Searches for tab-complete suggestions for the given command line.This is similar to
dispatchCommand(CommandSender, String, List)called with a list, but it also handles completing the command names itself instead of just the arguments.- Parameters:
sender- The command sendercommandLine- The current command line- Returns:
- The tab-complete suggestions
-
getBrigadierCompletions
public CompletableFuture<com.mojang.brigadier.suggestion.Suggestions> getBrigadierCompletions(CommandSender sender, String commandLine) -
getPlugins
Returns thePluginobjects corresponding to all loaded plugins.- Returns:
- the set of loaded plugins
-
getPlugin
Returns a loaded plugin identified by the specified name.- Parameters:
name- of the plugin to retrieve- Returns:
- the retrieved plugin or null if not loaded
-
loadPlugins
public void loadPlugins() -
enablePlugins
public void enablePlugins() -
detectPlugins
Load all plugins from the specified folder.- Parameters:
folder- the folder to search for plugins in
-
callEvent
Dispatch an event to all subscribed listeners and return the event once it has been handled by these listeners.- Type Parameters:
T- the type bounds, must be a class which extends event- Parameters:
event- the event to call- Returns:
- the called event
-
registerListener
Register aListenerfor receiving called events. Methods in this Object which wish to receive events must be annotated with theEventHandlerannotation.- Parameters:
plugin- the owning pluginlistener- the listener to register events for
-
unregisterListener
Unregister aListenerso that the events do not reach it anymore.- Parameters:
listener- the listener to unregister
-
unregisterListeners
Unregister all of a Plugin's listener.- Parameters:
plugin- target plugin
-
getCommands
Get an unmodifiable collection of all registered commands.- Returns:
- commands
-
disablePlugin
- Parameters:
pluginName- the plugin's name you want to disable- Throws:
IllegalArgumentException- if plugin name is null/empty || found plugin is null- See Also:
-
disablePlugin
Disables the specified plugin, if it is enabled.- Parameters:
plugin- the plugin you want to disable- Throws:
IllegalArgumentException- if the plugin is null
-
isPluginEnabled
- Parameters:
pluginName- the plugin's name you want to check- Returns:
trueif enabled, otherwisefalse- Throws:
IllegalArgumentException- if plugin name is null/empty || found plugin is null- See Also:
-
isPluginEnabled
Returns whenever a plugin is enabled- Parameters:
plugin- plugin- Returns:
trueif enabled, otherwisefalse- Throws:
IllegalArgumentException- if plugin is null
-
getCommandsAsBrigadier
Gets all registered commands as brigadier commands.- Returns:
- unmodifiable collection of brigadier commands
-