public final class PluginManager extends Object
Constructor and Description |
---|
PluginManager(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) |
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.
|
void |
disablePlugin(Plugin plugin)
Disables the specified plugin, if it is enabled.
|
void |
disablePlugin(String pluginName) |
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() |
CompletableFuture<com.mojang.brigadier.suggestion.Suggestions> |
getBrigadierCompletions(CommandSender sender,
String commandLine) |
Command |
getCommand(String name)
Deprecated.
internal use only in order to support waterfall's ProxyDefineCommandsEvent
|
Collection<Map.Entry<String,Command>> |
getCommands()
Get an unmodifiable collection of all registered commands.
|
Collection<com.mojang.brigadier.tree.CommandNode<CommandSender>> |
getCommandsAsBrigadier()
Gets all registered commands as brigadier 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).
|
boolean |
isPluginEnabled(Plugin plugin)
Returns whenever a plugin is enabled
|
boolean |
isPluginEnabled(String pluginName) |
void |
loadPlugins() |
void |
registerCommand(BrigadierCommand command) |
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. |
List<String> |
tabCompleteCommand(CommandSender sender,
String commandLine)
Searches for tab-complete suggestions for the given command line.
|
void |
unregisterCommand(BrigadierCommand command) |
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, MethodHandles.Lookup lookup, Consumer<Object> additionalEventListenerRegistration)
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)
public void registerCommand(Plugin plugin, Command command)
plugin
- the plugin owning this commandcommand
- the command to registerpublic void registerCommand(BrigadierCommand command)
public void unregisterCommand(BrigadierCommand command)
public 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 command@Deprecated public Command getCommand(String name)
name
- command name/aliaspublic 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 List<String> tabCompleteCommand(CommandSender sender, String commandLine)
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.
sender
- The command sendercommandLine
- The current command linepublic CompletableFuture<com.mojang.brigadier.suggestion.Suggestions> getBrigadierCompletions(CommandSender sender, String commandLine)
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()
public void disablePlugin(String pluginName)
pluginName
- the plugin's name you want to disableIllegalArgumentException
- if plugin name is null/empty || found plugin is nulldisablePlugin(Plugin)
public void disablePlugin(Plugin plugin)
plugin
- the plugin you want to disableIllegalArgumentException
- if the plugin is nullpublic boolean isPluginEnabled(String pluginName)
pluginName
- the plugin's name you want to checktrue
if enabled, otherwise false
IllegalArgumentException
- if plugin name is null/empty || found plugin is nullisPluginEnabled(Plugin)
public boolean isPluginEnabled(Plugin plugin)
plugin
- plugintrue
if enabled, otherwise false
IllegalArgumentException
- if plugin is nullpublic Collection<com.mojang.brigadier.tree.CommandNode<CommandSender>> getCommandsAsBrigadier()
Copyright © 2019–2022. All rights reserved.