Class SimplePluginManager
- java.lang.Object
-
- org.bukkit.plugin.SimplePluginManager
-
- All Implemented Interfaces:
PluginManager
public final class SimplePluginManager extends Object implements PluginManager
Handles all plugin management from the Server
-
-
Constructor Summary
Constructors Constructor Description SimplePluginManager(Server instance, SimpleCommandMap commandMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddPermission(Permission perm)Adds aPermissionto this plugin manager.voidaddPermission(Permission perm, boolean dirty)Deprecated.voidcallEvent(Event event)Calls an event with the given details.voidclearPlugins()Disables and removes all pluginsvoiddirtyPermissibles()Deprecated.voiddisablePlugin(Plugin plugin)Disables the specified pluginvoiddisablePlugins()Disables all the loaded pluginsvoidenablePlugin(Plugin plugin)Enables the specified pluginSet<Permission>getDefaultPermissions(boolean op)Gets the default permissions for the given op statusSet<Permissible>getDefaultPermSubscriptions(boolean op)Gets a set containing all subscribedPermissibles to the given default list, by op statusPermissiongetPermission(String name)Gets aPermissionfrom its fully qualified nameSet<Permission>getPermissions()Gets a set of all registered permissions.Set<Permissible>getPermissionSubscriptions(String permission)Gets a set containing all subscribedPermissibles to the given permission, by namePlugingetPlugin(String name)Checks if the given plugin is loaded and returns it when applicablePlugin[]getPlugins()Gets a list of all currently loaded pluginsbooleanisPluginEnabled(String name)Checks if the given plugin is enabled or notbooleanisPluginEnabled(Plugin plugin)Checks if the given plugin is enabled or notPluginloadPlugin(File file)Loads the plugin in the specified filePlugin[]loadPlugins(File directory)Loads the plugins contained within the specified directoryvoidrecalculatePermissionDefaults(Permission perm)Recalculates the defaults for the givenPermission.voidregisterEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin)Registers the specified executor to the given event classvoidregisterEvent(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 EventExecutorvoidregisterEvents(Listener listener, Plugin plugin)Registers all the events in the given listener classvoidregisterInterface(Class<? extends PluginLoader> loader)Registers the specified plugin loadervoidremovePermission(String name)Removes aPermissionregistration from this plugin manager.voidremovePermission(Permission perm)Removes aPermissionregistration from this plugin manager.voidsubscribeToDefaultPerms(boolean op, Permissible permissible)Subscribes to the given Default permissions by operator statusvoidsubscribeToPermission(String permission, Permissible permissible)Subscribes the given Permissible for information about the requested Permission, by name.voidunsubscribeFromDefaultPerms(boolean op, Permissible permissible)Unsubscribes from the given Default permissions by operator statusvoidunsubscribeFromPermission(String permission, Permissible permissible)Unsubscribes the given Permissible for information about the requested Permission, by name.booleanuseTimings()Returns whether or not timing code should be used for event callsvoiduseTimings(boolean use)Sets whether or not per event timing code should be used
-
-
-
Constructor Detail
-
SimplePluginManager
public SimplePluginManager(@NotNull Server instance, @NotNull SimpleCommandMap commandMap)
-
-
Method Detail
-
registerInterface
public void registerInterface(@NotNull Class<? extends PluginLoader> loader) throws IllegalArgumentExceptionRegisters the specified plugin loader- Specified by:
registerInterfacein interfacePluginManager- Parameters:
loader- Class name of the PluginLoader to register- Throws:
IllegalArgumentException- Thrown when the given Class is not a valid PluginLoader
-
loadPlugins
@NotNull public Plugin[] loadPlugins(@NotNull File directory)
Loads the plugins contained within the specified directory- Specified by:
loadPluginsin 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, UnknownDependencyException
Loads the plugin in the specified fileFile must be valid according to the current enabled Plugin interfaces
- Specified by:
loadPluginin 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
@Nullable public Plugin getPlugin(@NotNull String name)
Checks if the given plugin is loaded and returns it when applicablePlease note that the name of the plugin is case-sensitive
- Specified by:
getPluginin interfacePluginManager- Parameters:
name- Name of the plugin to check- Returns:
- Plugin if it exists, otherwise null
-
getPlugins
@NotNull public Plugin[] getPlugins()
Description copied from interface:PluginManagerGets a list of all currently loaded plugins- Specified by:
getPluginsin interfacePluginManager- Returns:
- Array of Plugins
-
isPluginEnabled
public boolean isPluginEnabled(@NotNull String name)Checks if the given plugin is enabled or notPlease note that the name of the plugin is case-sensitive.
- Specified by:
isPluginEnabledin interfacePluginManager- Parameters:
name- Name of the plugin to check- Returns:
- true if the plugin is enabled, otherwise false
-
isPluginEnabled
public boolean isPluginEnabled(@Nullable Plugin plugin)Checks if the given plugin is enabled or not- Specified by:
isPluginEnabledin interfacePluginManager- Parameters:
plugin- Plugin to check- Returns:
- true if the plugin is enabled, otherwise false
-
enablePlugin
public void enablePlugin(@NotNull Plugin plugin)Description copied from interface:PluginManagerEnables the specified pluginAttempting to enable a plugin that is already enabled will have no effect
- Specified by:
enablePluginin interfacePluginManager- Parameters:
plugin- Plugin to enable
-
disablePlugins
public void disablePlugins()
Description copied from interface:PluginManagerDisables all the loaded plugins- Specified by:
disablePluginsin interfacePluginManager
-
disablePlugin
public void disablePlugin(@NotNull Plugin plugin)Description copied from interface:PluginManagerDisables the specified pluginAttempting to disable a plugin that is not enabled will have no effect
- Specified by:
disablePluginin interfacePluginManager- Parameters:
plugin- Plugin to disable
-
clearPlugins
public void clearPlugins()
Description copied from interface:PluginManagerDisables and removes all plugins- Specified by:
clearPluginsin interfacePluginManager
-
callEvent
public void callEvent(@NotNull Event event)Calls an event with the given details.This method only synchronizes when the event is not asynchronous.
- Specified by:
callEventin interfacePluginManager- Parameters:
event- Event details
-
registerEvents
public void registerEvents(@NotNull Listener listener, @NotNull Plugin plugin)Description copied from interface:PluginManagerRegisters all the events in the given listener class- Specified by:
registerEventsin 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:PluginManagerRegisters the specified executor to the given event class- Specified by:
registerEventin 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:
registerEventin 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
@Nullable public Permission getPermission(@NotNull String name)
Description copied from interface:PluginManagerGets aPermissionfrom its fully qualified name- Specified by:
getPermissionin interfacePluginManager- Parameters:
name- Name of the permission- Returns:
- Permission, or null if none
-
addPermission
public void addPermission(@NotNull Permission perm)Description copied from interface:PluginManagerAdds aPermissionto this plugin manager.If a permission is already defined with the given name of the new permission, an exception will be thrown.
- Specified by:
addPermissionin interfacePluginManager- Parameters:
perm- Permission to add
-
addPermission
@Deprecated public void addPermission(@NotNull Permission perm, boolean dirty)
Deprecated.
-
getDefaultPermissions
@NotNull public Set<Permission> getDefaultPermissions(boolean op)
Description copied from interface:PluginManagerGets the default permissions for the given op status- Specified by:
getDefaultPermissionsin interfacePluginManager- Parameters:
op- Which set of default permissions to get- Returns:
- The default permissions
-
removePermission
public void removePermission(@NotNull Permission perm)Description copied from interface:PluginManagerRemoves aPermissionregistration 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.- Specified by:
removePermissionin interfacePluginManager- Parameters:
perm- Permission to remove
-
removePermission
public void removePermission(@NotNull String name)Description copied from interface:PluginManagerRemoves aPermissionregistration 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.- Specified by:
removePermissionin interfacePluginManager- Parameters:
name- Permission to remove
-
recalculatePermissionDefaults
public void recalculatePermissionDefaults(@NotNull Permission perm)Description copied from interface:PluginManagerRecalculates the defaults for the givenPermission.This will have no effect if the specified permission is not registered here.
- Specified by:
recalculatePermissionDefaultsin interfacePluginManager- Parameters:
perm- Permission to recalculate
-
dirtyPermissibles
@Deprecated public void dirtyPermissibles()
Deprecated.
-
subscribeToPermission
public void subscribeToPermission(@NotNull String permission, @NotNull Permissible permissible)Description copied from interface:PluginManagerSubscribes 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:
subscribeToPermissionin interfacePluginManager- Parameters:
permission- Permission to subscribe topermissible- Permissible subscribing
-
unsubscribeFromPermission
public void unsubscribeFromPermission(@NotNull String permission, @NotNull Permissible permissible)Description copied from interface:PluginManagerUnsubscribes the given Permissible for information about the requested Permission, by name.- Specified by:
unsubscribeFromPermissionin interfacePluginManager- Parameters:
permission- Permission to unsubscribe frompermissible- Permissible subscribing
-
getPermissionSubscriptions
@NotNull public Set<Permissible> getPermissionSubscriptions(@NotNull String permission)
Description copied from interface:PluginManagerGets a set containing all subscribedPermissibles to the given permission, by name- Specified by:
getPermissionSubscriptionsin interfacePluginManager- Parameters:
permission- Permission to query for- Returns:
- Set containing all subscribed permissions
-
subscribeToDefaultPerms
public void subscribeToDefaultPerms(boolean op, @NotNull Permissible permissible)Description copied from interface:PluginManagerSubscribes to the given Default permissions by operator statusIf the specified defaults change in any form, the Permissible will be asked to recalculate.
- Specified by:
subscribeToDefaultPermsin interfacePluginManager- Parameters:
op- Default list to subscribe topermissible- Permissible subscribing
-
unsubscribeFromDefaultPerms
public void unsubscribeFromDefaultPerms(boolean op, @NotNull Permissible permissible)Description copied from interface:PluginManagerUnsubscribes from the given Default permissions by operator status- Specified by:
unsubscribeFromDefaultPermsin interfacePluginManager- Parameters:
op- Default list to unsubscribe frompermissible- Permissible subscribing
-
getDefaultPermSubscriptions
@NotNull public Set<Permissible> getDefaultPermSubscriptions(boolean op)
Description copied from interface:PluginManagerGets a set containing all subscribedPermissibles to the given default list, by op status- Specified by:
getDefaultPermSubscriptionsin interfacePluginManager- Parameters:
op- Default list to query for- Returns:
- Set containing all subscribed permissions
-
getPermissions
@NotNull public Set<Permission> getPermissions()
Description copied from interface:PluginManagerGets a set of all registered permissions.This set is a copy and will not be modified live.
- Specified by:
getPermissionsin interfacePluginManager- Returns:
- Set containing all current registered permissions
-
useTimings
public boolean useTimings()
Description copied from interface:PluginManagerReturns whether or not timing code should be used for event calls- Specified by:
useTimingsin 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
-
-