Interface PluginManager
- All Known Implementing Classes:
SimplePluginManager
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPermission(@NotNull Permission perm)
Adds aPermission
to this plugin manager.void
Calls an event with the given detailsvoid
Disables and removes all pluginsvoid
disablePlugin(@NotNull Plugin plugin)
Disables the specified plugindefault void
disablePlugin(@NotNull Plugin plugin, boolean closeClassloader)
Deprecated, for removal: This API element is subject to removal in a future version.Classloader is always closed by upstream now.void
Disables all the loaded pluginsvoid
enablePlugin(@NotNull Plugin plugin)
Enables the specified plugingetDefaultPermissions(boolean op)
Gets the default permissions for the given op statusgetDefaultPermSubscriptions(boolean op)
Gets a set containing all subscribedPermissible
s to the given default list, by op statusgetPermission(@NotNull String name)
Gets aPermission
from its fully qualified nameGets a set of all registered permissions.getPermissionSubscriptions(@NotNull String permission)
Gets a set containing all subscribedPermissible
s to the given permission, by nameChecks if the given plugin is loaded and returns it when applicableGets a list of all currently loaded pluginsboolean
isPluginEnabled(@NotNull String name)
Checks if the given plugin is enabled or notboolean
isPluginEnabled(@Nullable Plugin plugin)
Checks if the given plugin is enabled or notloadPlugin(@NotNull File file)
Loads the plugin in the specified fileloadPlugins(@NotNull File directory)
Loads the plugins contained within the specified directoryvoid
Recalculates the defaults for the givenPermission
.void
registerEvent(@NotNull Class<? extends Event> event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin)
Registers the specified executor to the given event classvoid
registerEvent(@NotNull Class<? extends Event> event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin, boolean ignoreCancelled)
Registers the specified executor to the given event classvoid
registerEvents(@NotNull Listener listener, @NotNull Plugin plugin)
Registers all the events in the given listener classvoid
registerInterface(@NotNull Class<? extends PluginLoader> loader)
Registers the specified plugin loadervoid
removePermission(@NotNull String name)
Removes aPermission
registration from this plugin manager.void
removePermission(@NotNull Permission perm)
Removes aPermission
registration from this plugin manager.void
subscribeToDefaultPerms(boolean op, @NotNull Permissible permissible)
Subscribes to the given Default permissions by operator statusvoid
subscribeToPermission(@NotNull String permission, @NotNull Permissible permissible)
Subscribes the given Permissible for information about the requested Permission, by name.void
unsubscribeFromDefaultPerms(boolean op, @NotNull Permissible permissible)
Unsubscribes from the given Default permissions by operator statusvoid
unsubscribeFromPermission(@NotNull String permission, @NotNull Permissible permissible)
Unsubscribes the given Permissible for information about the requested Permission, by name.boolean
Returns whether or not timing code should be used for event calls
-
Method Details
-
registerInterface
void registerInterface(@NotNull @NotNull Class<? extends PluginLoader> loader) throws IllegalArgumentExceptionRegisters 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
Checks if the given plugin is loaded and returns it when applicablePlease 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
Gets a list of all currently loaded plugins- Returns:
- Array of Plugins
-
isPluginEnabled
Checks if the given plugin is enabled or notPlease 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
Checks if the given plugin is enabled or not- Parameters:
plugin
- Plugin to check- Returns:
- true if the plugin is enabled, otherwise false
-
loadPlugin
@Nullable @Nullable Plugin loadPlugin(@NotNull @NotNull File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyExceptionLoads the plugin in the specified fileFile must be valid according to the current enabled Plugin interfaces
- Parameters:
file
- File containing the plugin to load- Returns:
- The Plugin loaded, or null if it was invalid
- Throws:
InvalidPluginException
- Thrown when the specified file is not a valid pluginInvalidDescriptionException
- Thrown when the specified file contains an invalid descriptionUnknownDependencyException
- If a required dependency could not be resolved
-
loadPlugins
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
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
Registers all the events in the given listener class- Parameters:
listener
- Listener to registerplugin
- 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 registerlistener
- Listener to registerpriority
- Priority to register this event atexecutor
- EventExecutor to registerplugin
- 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 registerlistener
- Listener to registerpriority
- Priority to register this event atexecutor
- EventExecutor to registerplugin
- Plugin to registerignoreCancelled
- Whether to pass cancelled events or not
-
enablePlugin
Enables the specified pluginAttempting to enable a plugin that is already enabled will have no effect
- Parameters:
plugin
- Plugin to enable
-
disablePlugin
Disables the specified pluginAttempting to disable a plugin that is not enabled will have no effect
- Parameters:
plugin
- Plugin to disable
-
disablePlugin
@Deprecated(forRemoval=true) default void disablePlugin(@NotNull @NotNull Plugin plugin, boolean closeClassloader)Deprecated, for removal: This API element is subject to removal in a future version.Classloader is always closed by upstream now.This method is no longer useful as upstream has made it so plugin classloaders are always closed on disable. UsedisablePlugin(Plugin)
instead.- Parameters:
plugin
- Plugin to disablecloseClassloader
- unused
-
getPermission
Gets aPermission
from its fully qualified name- Parameters:
name
- Name of the permission- Returns:
- Permission, or null if none
-
addPermission
Adds aPermission
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
Removes aPermission
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
Permissible
s that have it.- Parameters:
perm
- Permission to remove
-
removePermission
Removes aPermission
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
Permissible
s that have it.- Parameters:
name
- Permission to remove
-
getDefaultPermissions
Gets the default permissions for the given op status- Parameters:
op
- Which set of default permissions to get- Returns:
- The default permissions
-
recalculatePermissionDefaults
Recalculates the defaults for the givenPermission
.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 topermissible
- 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 frompermissible
- Permissible subscribing
-
getPermissionSubscriptions
Gets a set containing all subscribedPermissible
s to the given permission, by name- Parameters:
permission
- Permission to query for- Returns:
- Set containing all subscribed permissions
-
subscribeToDefaultPerms
Subscribes to the given Default permissions by operator statusIf the specified defaults change in any form, the Permissible will be asked to recalculate.
- Parameters:
op
- Default list to subscribe topermissible
- Permissible subscribing
-
unsubscribeFromDefaultPerms
Unsubscribes from the given Default permissions by operator status- Parameters:
op
- Default list to unsubscribe frompermissible
- Permissible subscribing
-
getDefaultPermSubscriptions
Gets a set containing all subscribedPermissible
s to the given default list, by op status- Parameters:
op
- Default list to query for- Returns:
- Set containing all subscribed permissions
-
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
-