Interface PluginManager

  • All Known Implementing Classes:
    SimplePluginManager

    public interface PluginManager
    Handles all plugin management from the Server
    • Method Detail

      • registerInterface

        void registerInterface​(@NotNull
                               @NotNull Class<? extends PluginLoader> loader)
                        throws IllegalArgumentException
        Registers the specified plugin loader
        Parameters:
        loader - Class name of the PluginLoader to register
        Throws:
        IllegalArgumentException - Thrown when the given Class is not a valid PluginLoader
      • getPlugin

        @Nullable
        @Nullable Plugin getPlugin​(@NotNull
                                   @NotNull String name)
        Checks if the given plugin is loaded and returns it when applicable

        Please note that the name of the plugin is case-sensitive

        Parameters:
        name - Name of the plugin to check
        Returns:
        Plugin if it exists, otherwise null
      • getPlugins

        @NotNull
        @NotNull Plugin[] getPlugins()
        Gets a list of all currently loaded plugins
        Returns:
        Array of Plugins
      • isPluginEnabled

        boolean isPluginEnabled​(@NotNull
                                @NotNull String name)
        Checks if the given plugin is enabled or not

        Please note that the name of the plugin is case-sensitive.

        Parameters:
        name - Name of the plugin to check
        Returns:
        true if the plugin is enabled, otherwise false
      • isPluginEnabled

        @Contract("null -> false")
        boolean isPluginEnabled​(@Nullable
                                @Nullable Plugin plugin)
        Checks if the given plugin is enabled or not
        Parameters:
        plugin - Plugin to check
        Returns:
        true if the plugin is enabled, otherwise false
      • loadPlugins

        @NotNull
        @NotNull Plugin[] loadPlugins​(@NotNull
                                      @NotNull File directory)
        Loads the plugins contained within the specified directory
        Parameters:
        directory - Directory to check for plugins
        Returns:
        A list of all plugins loaded
      • disablePlugins

        void disablePlugins()
        Disables all the loaded plugins
      • clearPlugins

        void clearPlugins()
        Disables and removes all plugins
      • callEvent

        void callEvent​(@NotNull
                       @NotNull Event event)
                throws IllegalStateException
        Calls an event with the given details
        Parameters:
        event - Event details
        Throws:
        IllegalStateException - Thrown when an asynchronous event is fired from synchronous code.

        Note: This is best-effort basis, and should not be used to test synchronized state. This is an indicator for flawed flow logic.

      • registerEvents

        void registerEvents​(@NotNull
                            @NotNull Listener listener,
                            @NotNull
                            @NotNull Plugin plugin)
        Registers all the events in the given listener class
        Parameters:
        listener - Listener to register
        plugin - Plugin to register
      • registerEvent

        void registerEvent​(@NotNull
                           @NotNull Class<? extends Event> event,
                           @NotNull
                           @NotNull Listener listener,
                           @NotNull
                           @NotNull EventPriority priority,
                           @NotNull
                           @NotNull EventExecutor executor,
                           @NotNull
                           @NotNull Plugin plugin)
        Registers the specified executor to the given event class
        Parameters:
        event - Event type to register
        listener - Listener to register
        priority - Priority to register this event at
        executor - EventExecutor to register
        plugin - Plugin to register
      • registerEvent

        void registerEvent​(@NotNull
                           @NotNull Class<? extends Event> event,
                           @NotNull
                           @NotNull Listener listener,
                           @NotNull
                           @NotNull EventPriority priority,
                           @NotNull
                           @NotNull EventExecutor executor,
                           @NotNull
                           @NotNull Plugin plugin,
                           boolean ignoreCancelled)
        Registers the specified executor to the given event class
        Parameters:
        event - Event type to register
        listener - Listener to register
        priority - Priority to register this event at
        executor - EventExecutor to register
        plugin - Plugin to register
        ignoreCancelled - Whether to pass cancelled events or not
      • enablePlugin

        void enablePlugin​(@NotNull
                          @NotNull Plugin plugin)
        Enables the specified plugin

        Attempting to enable a plugin that is already enabled will have no effect

        Parameters:
        plugin - Plugin to enable
      • disablePlugin

        void disablePlugin​(@NotNull
                           @NotNull Plugin plugin)
        Disables the specified plugin

        Attempting to disable a plugin that is not enabled will have no effect

        Parameters:
        plugin - Plugin to disable
      • getPermission

        @Nullable
        @Nullable Permission getPermission​(@NotNull
                                           @NotNull String name)
        Gets a Permission from its fully qualified name
        Parameters:
        name - Name of the permission
        Returns:
        Permission, or null if none
      • addPermission

        void addPermission​(@NotNull
                           @NotNull Permission perm)
        Adds a Permission to this plugin manager.

        If a permission is already defined with the given name of the new permission, an exception will be thrown.

        Parameters:
        perm - Permission to add
        Throws:
        IllegalArgumentException - Thrown when a permission with the same name already exists
      • removePermission

        void removePermission​(@NotNull
                              @NotNull Permission perm)
        Removes a Permission registration from this plugin manager.

        If the specified permission does not exist in this plugin manager, nothing will happen.

        Removing a permission registration will not remove the permission from any Permissibles that have it.

        Parameters:
        perm - Permission to remove
      • removePermission

        void removePermission​(@NotNull
                              @NotNull String name)
        Removes a Permission registration from this plugin manager.

        If the specified permission does not exist in this plugin manager, nothing will happen.

        Removing a permission registration will not remove the permission from any Permissibles that have it.

        Parameters:
        name - Permission to remove
      • getDefaultPermissions

        @NotNull
        @NotNull Set<Permission> getDefaultPermissions​(boolean op)
        Gets the default permissions for the given op status
        Parameters:
        op - Which set of default permissions to get
        Returns:
        The default permissions
      • recalculatePermissionDefaults

        void recalculatePermissionDefaults​(@NotNull
                                           @NotNull Permission perm)
        Recalculates the defaults for the given Permission.

        This will have no effect if the specified permission is not registered here.

        Parameters:
        perm - Permission to recalculate
      • subscribeToPermission

        void subscribeToPermission​(@NotNull
                                   @NotNull String permission,
                                   @NotNull
                                   @NotNull Permissible permissible)
        Subscribes the given Permissible for information about the requested Permission, by name.

        If the specified Permission changes in any form, the Permissible will be asked to recalculate.

        Parameters:
        permission - Permission to subscribe to
        permissible - Permissible subscribing
      • unsubscribeFromPermission

        void unsubscribeFromPermission​(@NotNull
                                       @NotNull String permission,
                                       @NotNull
                                       @NotNull Permissible permissible)
        Unsubscribes the given Permissible for information about the requested Permission, by name.
        Parameters:
        permission - Permission to unsubscribe from
        permissible - Permissible subscribing
      • getPermissionSubscriptions

        @NotNull
        @NotNull Set<Permissible> getPermissionSubscriptions​(@NotNull
                                                             @NotNull String permission)
        Gets a set containing all subscribed Permissibles to the given permission, by name
        Parameters:
        permission - Permission to query for
        Returns:
        Set containing all subscribed permissions
      • subscribeToDefaultPerms

        void subscribeToDefaultPerms​(boolean op,
                                     @NotNull
                                     @NotNull Permissible permissible)
        Subscribes to the given Default permissions by operator status

        If the specified defaults change in any form, the Permissible will be asked to recalculate.

        Parameters:
        op - Default list to subscribe to
        permissible - Permissible subscribing
      • unsubscribeFromDefaultPerms

        void unsubscribeFromDefaultPerms​(boolean op,
                                         @NotNull
                                         @NotNull Permissible permissible)
        Unsubscribes from the given Default permissions by operator status
        Parameters:
        op - Default list to unsubscribe from
        permissible - Permissible subscribing
      • getDefaultPermSubscriptions

        @NotNull
        @NotNull Set<Permissible> getDefaultPermSubscriptions​(boolean op)
        Gets a set containing all subscribed Permissibles to the given default list, by op status
        Parameters:
        op - Default list to query for
        Returns:
        Set containing all subscribed permissions
      • getPermissions

        @NotNull
        @NotNull Set<Permission> getPermissions()
        Gets a set of all registered permissions.

        This set is a copy and will not be modified live.

        Returns:
        Set containing all current registered permissions
      • useTimings

        boolean useTimings()
        Returns whether or not timing code should be used for event calls
        Returns:
        True if event timings are to be used