Class PluginManager

java.lang.Object
net.md_5.bungee.api.plugin.PluginManager

public final class PluginManager extends Object
Class to manage bridging between plugin duties and implementation duties, for example event handling and plugin management.
  • Constructor Details

    • PluginManager

      public PluginManager(ProxyServer proxy)
  • Method Details

    • registerCommand

      public void registerCommand(Plugin plugin, Command command)
      Register a command so that it may be executed.
      Parameters:
      plugin - the plugin owning this command
      command - the command to register
    • unregisterCommand

      public void unregisterCommand(Command command)
      Unregister a command so it will no longer be executed.
      Parameters:
      command - the command to unregister
    • unregisterCommands

      public void unregisterCommands(Plugin plugin)
      Unregister all commands owned by a Plugin
      Parameters:
      plugin - the plugin to register the commands of
    • isExecutableCommand

      public 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).
      Parameters:
      commandName - the name of the command
      sender - the sender executing the command
      Returns:
      whether the command will be handled
    • dispatchCommand

      public boolean dispatchCommand(CommandSender sender, String commandLine)
    • dispatchCommand

      public boolean dispatchCommand(CommandSender sender, String commandLine, List<String> tabResults)
      Execute a command if it is registered, else return false.
      Parameters:
      sender - the sender executing the command
      commandLine - the complete command line including command name and arguments
      tabResults - 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
    • getPlugins

      public Collection<Plugin> getPlugins()
      Returns the Plugin objects corresponding to all loaded plugins.
      Returns:
      the set of loaded plugins
    • getPlugin

      public Plugin getPlugin(String name)
      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

      public void detectPlugins(File folder)
      Load all plugins from the specified folder.
      Parameters:
      folder - the folder to search for plugins in
    • callEvent

      public <T extends Event> T callEvent(T event)
      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

      public void registerListener(Plugin plugin, Listener listener)
      Register a Listener for receiving called events. Methods in this Object which wish to receive events must be annotated with the EventHandler annotation.
      Parameters:
      plugin - the owning plugin
      listener - the listener to register events for
    • unregisterListener

      public void unregisterListener(Listener listener)
      Unregister a Listener so that the events do not reach it anymore.
      Parameters:
      listener - the listener to unregister
    • unregisterListeners

      public void unregisterListeners(Plugin plugin)
      Unregister all of a Plugin's listener.
      Parameters:
      plugin - target plugin
    • getCommands

      public Collection<Map.Entry<String,Command>> getCommands()
      Get an unmodifiable collection of all registered commands.
      Returns:
      commands