Class SimplePluginManager
- All Implemented Interfaces:
PluginManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPermission(Permission perm)
Adds aPermission
to this plugin manager.void
addPermission(Permission perm, boolean dirty)
Deprecated.void
Calls an event with the given details.void
Disables and removes all pluginsvoid
Deprecated.void
disablePlugin(Plugin plugin)
Disables the specified pluginvoid
Disables all the loaded pluginsvoid
enablePlugin(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(String name)
Gets aPermission
from its fully qualified nameGets a set of all registered permissions.getPermissionSubscriptions(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 applicablePlugin[]
Gets a list of all currently loaded pluginsboolean
isPluginEnabled(String name)
Checks if the given plugin is enabled or notboolean
isPluginEnabled(Plugin plugin)
Checks if the given plugin is enabled or notboolean
isTransitiveDepend(PluginDescriptionFile plugin, PluginDescriptionFile depend)
loadPlugin(File file)
Loads the plugin in the specified filePlugin[]
loadPlugins(File directory)
Loads the plugins contained within the specified directoryvoid
Recalculates the defaults for the givenPermission
.void
registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin)
Registers the specified executor to the given event classvoid
registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin, boolean ignoreCancelled)
Registers the given event to the specified listener using a directly passed EventExecutorvoid
registerEvents(Listener listener, Plugin plugin)
Registers all the events in the given listener classvoid
registerInterface(Class<? extends PluginLoader> loader)
Registers the specified plugin loadervoid
removePermission(String name)
Removes aPermission
registration from this plugin manager.void
removePermission(Permission perm)
Removes aPermission
registration from this plugin manager.void
subscribeToDefaultPerms(boolean op, Permissible permissible)
Subscribes to the given Default permissions by operator statusvoid
subscribeToPermission(String permission, Permissible permissible)
Subscribes the given Permissible for information about the requested Permission, by name.void
unsubscribeFromDefaultPerms(boolean op, Permissible permissible)
Unsubscribes from the given Default permissions by operator statusvoid
unsubscribeFromPermission(String permission, 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 callsvoid
useTimings(boolean use)
Sets whether or not per event timing code should be used
-
Constructor Details
-
SimplePluginManager
-
-
Method Details
-
registerInterface
public void registerInterface(@NotNull Class<? extends PluginLoader> loader) throws IllegalArgumentExceptionRegisters the specified plugin loader- Specified by:
registerInterface
in interfacePluginManager
- Parameters:
loader
- Class name of the PluginLoader to register- Throws:
IllegalArgumentException
- Thrown when the given Class is not a valid PluginLoader
-
loadPlugins
Loads the plugins contained within the specified directory- Specified by:
loadPlugins
in interfacePluginManager
- Parameters:
directory
- Directory to check for plugins- Returns:
- A list of all plugins loaded
-
loadPlugin
@Nullable public Plugin loadPlugin(@NotNull File file) throws InvalidPluginException, UnknownDependencyExceptionLoads the plugin in the specified fileFile must be valid according to the current enabled Plugin interfaces
- Specified by:
loadPlugin
in interfacePluginManager
- 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 pluginUnknownDependencyException
- If a required dependency could not be found
-
getPlugin
Checks if the given plugin is loaded and returns it when applicablePlease note that the name of the plugin is case-sensitive
- Specified by:
getPlugin
in interfacePluginManager
- Parameters:
name
- Name of the plugin to check- Returns:
- Plugin if it exists, otherwise null
-
getPlugins
Description copied from interface:PluginManager
Gets a list of all currently loaded plugins- Specified by:
getPlugins
in interfacePluginManager
- Returns:
- Array of Plugins
-
isPluginEnabled
Checks if the given plugin is enabled or notPlease note that the name of the plugin is case-sensitive.
- Specified by:
isPluginEnabled
in interfacePluginManager
- 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- Specified by:
isPluginEnabled
in interfacePluginManager
- Parameters:
plugin
- Plugin to check- Returns:
- true if the plugin is enabled, otherwise false
-
enablePlugin
Description copied from interface:PluginManager
Enables the specified pluginAttempting to enable a plugin that is already enabled will have no effect
- Specified by:
enablePlugin
in interfacePluginManager
- Parameters:
plugin
- Plugin to enable
-
disablePlugins
public void disablePlugins()Description copied from interface:PluginManager
Disables all the loaded plugins- Specified by:
disablePlugins
in interfacePluginManager
-
disablePlugin
Description copied from interface:PluginManager
Disables the specified pluginAttempting to disable a plugin that is not enabled will have no effect
- Specified by:
disablePlugin
in interfacePluginManager
- Parameters:
plugin
- Plugin to disable
-
clearPlugins
public void clearPlugins()Description copied from interface:PluginManager
Disables and removes all plugins- Specified by:
clearPlugins
in interfacePluginManager
-
callEvent
Calls an event with the given details.- Specified by:
callEvent
in interfacePluginManager
- Parameters:
event
- Event details
-
registerEvents
Description copied from interface:PluginManager
Registers all the events in the given listener class- Specified by:
registerEvents
in interfacePluginManager
- Parameters:
listener
- Listener to registerplugin
- Plugin to register
-
registerEvent
public void registerEvent(@NotNull Class<? extends Event> event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin)Description copied from interface:PluginManager
Registers the specified executor to the given event class- Specified by:
registerEvent
in interfacePluginManager
- Parameters:
event
- Event type to registerlistener
- Listener to registerpriority
- Priority to register this event atexecutor
- EventExecutor to registerplugin
- Plugin to register
-
registerEvent
public void registerEvent(@NotNull Class<? extends Event> event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin, boolean ignoreCancelled)Registers the given event to the specified listener using a directly passed EventExecutor- Specified by:
registerEvent
in interfacePluginManager
- Parameters:
event
- Event class to registerlistener
- PlayerListener to registerpriority
- Priority of this eventexecutor
- EventExecutor to registerplugin
- Plugin to registerignoreCancelled
- Do not call executor if event was already cancelled
-
getPermission
Description copied from interface:PluginManager
Gets aPermission
from its fully qualified name- Specified by:
getPermission
in interfacePluginManager
- Parameters:
name
- Name of the permission- Returns:
- Permission, or null if none
-
addPermission
Description copied from interface:PluginManager
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.
- Specified by:
addPermission
in interfacePluginManager
- Parameters:
perm
- Permission to add
-
addPermission
Deprecated. -
getDefaultPermissions
Description copied from interface:PluginManager
Gets the default permissions for the given op status- Specified by:
getDefaultPermissions
in interfacePluginManager
- Parameters:
op
- Which set of default permissions to get- Returns:
- The default permissions
-
removePermission
Description copied from interface:PluginManager
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.- Specified by:
removePermission
in interfacePluginManager
- Parameters:
perm
- Permission to remove
-
removePermission
Description copied from interface:PluginManager
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.- Specified by:
removePermission
in interfacePluginManager
- Parameters:
name
- Permission to remove
-
recalculatePermissionDefaults
Description copied from interface:PluginManager
Recalculates the defaults for the givenPermission
.This will have no effect if the specified permission is not registered here.
- Specified by:
recalculatePermissionDefaults
in interfacePluginManager
- Parameters:
perm
- Permission to recalculate
-
dirtyPermissibles
Deprecated. -
subscribeToPermission
Description copied from interface:PluginManager
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.
- Specified by:
subscribeToPermission
in interfacePluginManager
- Parameters:
permission
- Permission to subscribe topermissible
- Permissible subscribing
-
unsubscribeFromPermission
public void unsubscribeFromPermission(@NotNull String permission, @NotNull Permissible permissible)Description copied from interface:PluginManager
Unsubscribes the given Permissible for information about the requested Permission, by name.- Specified by:
unsubscribeFromPermission
in interfacePluginManager
- Parameters:
permission
- Permission to unsubscribe frompermissible
- Permissible subscribing
-
getPermissionSubscriptions
Description copied from interface:PluginManager
Gets a set containing all subscribedPermissible
s to the given permission, by name- Specified by:
getPermissionSubscriptions
in interfacePluginManager
- Parameters:
permission
- Permission to query for- Returns:
- Set containing all subscribed permissions
-
subscribeToDefaultPerms
Description copied from interface:PluginManager
Subscribes to the given Default permissions by operator statusIf the specified defaults change in any form, the Permissible will be asked to recalculate.
- Specified by:
subscribeToDefaultPerms
in interfacePluginManager
- Parameters:
op
- Default list to subscribe topermissible
- Permissible subscribing
-
unsubscribeFromDefaultPerms
Description copied from interface:PluginManager
Unsubscribes from the given Default permissions by operator status- Specified by:
unsubscribeFromDefaultPerms
in interfacePluginManager
- Parameters:
op
- Default list to unsubscribe frompermissible
- Permissible subscribing
-
getDefaultPermSubscriptions
Description copied from interface:PluginManager
Gets a set containing all subscribedPermissible
s to the given default list, by op status- Specified by:
getDefaultPermSubscriptions
in interfacePluginManager
- Parameters:
op
- Default list to query for- Returns:
- Set containing all subscribed permissions
-
getPermissions
Description copied from interface:PluginManager
Gets a set of all registered permissions.This set is a copy and will not be modified live.
- Specified by:
getPermissions
in interfacePluginManager
- Returns:
- Set containing all current registered permissions
-
isTransitiveDepend
public boolean isTransitiveDepend(@NotNull PluginDescriptionFile plugin, @NotNull PluginDescriptionFile depend) -
useTimings
public boolean useTimings()Description copied from interface:PluginManager
Returns whether or not timing code should be used for event calls- Specified by:
useTimings
in interfacePluginManager
- Returns:
- True if event timings are to be used
-
useTimings
public void useTimings(boolean use)Sets whether or not per event timing code should be used- Parameters:
use
- True if per event timing code should be used
-