Package org.bukkit.plugin
Class SimpleServicesManager
java.lang.Object
org.bukkit.plugin.SimpleServicesManager
- All Implemented Interfaces:
ServicesManager
A simple services manager.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet a list of known services.getRegistration
(@NotNull Class<T> service) Queries for a provider registration.<T> @NotNull List
<RegisteredServiceProvider<T>> getRegistrations
(@NotNull Class<T> service) Get registrations of providers for a service.getRegistrations
(@NotNull Plugin plugin) Get registrations of providers for a plugin.<T> boolean
isProvidedFor
(@NotNull Class<T> service) Returns whether a provider has been registered for a service.<T> T
Queries for a provider.<T> void
register
(@NotNull Class<T> service, T provider, @NotNull Plugin plugin, @NotNull ServicePriority priority) Register a provider of a service.void
unregister
(@NotNull Class<?> service, @NotNull Object provider) Unregister a particular provider for a particular service.void
unregister
(@NotNull Object provider) Unregister a particular provider.void
unregisterAll
(@NotNull Plugin plugin) Unregister all the providers registered by a particular plugin.
-
Constructor Details
-
SimpleServicesManager
public SimpleServicesManager()
-
-
Method Details
-
register
public <T> void register(@NotNull @NotNull Class<T> service, @NotNull T provider, @NotNull @NotNull Plugin plugin, @NotNull @NotNull ServicePriority priority) Register a provider of a service.- Specified by:
register
in interfaceServicesManager
- Type Parameters:
T
- Provider- Parameters:
service
- service classprovider
- provider to registerplugin
- plugin with the providerpriority
- priority of the provider
-
unregisterAll
Unregister all the providers registered by a particular plugin.- Specified by:
unregisterAll
in interfaceServicesManager
- Parameters:
plugin
- The plugin
-
unregister
Unregister a particular provider for a particular service.- Specified by:
unregister
in interfaceServicesManager
- Parameters:
service
- The service interfaceprovider
- The service provider implementation
-
unregister
Unregister a particular provider.- Specified by:
unregister
in interfaceServicesManager
- Parameters:
provider
- The service provider implementation
-
load
Queries for a provider. This may return if no provider has been registered for a service. The highest priority provider is returned.- Specified by:
load
in interfaceServicesManager
- Type Parameters:
T
- The service interface- Parameters:
service
- The service interface- Returns:
- provider or null
-
getRegistration
@Nullable public <T> @Nullable RegisteredServiceProvider<T> getRegistration(@NotNull @NotNull Class<T> service) Queries for a provider registration. This may return if no provider has been registered for a service.- Specified by:
getRegistration
in interfaceServicesManager
- Type Parameters:
T
- The service interface- Parameters:
service
- The service interface- Returns:
- provider registration or null
-
getRegistrations
@NotNull public @NotNull List<RegisteredServiceProvider<?>> getRegistrations(@NotNull @NotNull Plugin plugin) Get registrations of providers for a plugin.- Specified by:
getRegistrations
in interfaceServicesManager
- Parameters:
plugin
- The plugin- Returns:
- provider registrations
-
getRegistrations
@NotNull public <T> @NotNull List<RegisteredServiceProvider<T>> getRegistrations(@NotNull @NotNull Class<T> service) Get registrations of providers for a service. The returned list is an unmodifiable copy.- Specified by:
getRegistrations
in interfaceServicesManager
- Type Parameters:
T
- The service interface- Parameters:
service
- The service interface- Returns:
- a copy of the list of registrations
-
getKnownServices
Get a list of known services. A service is known if it has registered providers for it.- Specified by:
getKnownServices
in interfaceServicesManager
- Returns:
- a copy of the set of known services
-
isProvidedFor
Returns whether a provider has been registered for a service.- Specified by:
isProvidedFor
in interfaceServicesManager
- Type Parameters:
T
- service- Parameters:
service
- service to check- Returns:
- true if and only if there are registered providers
-