接口 ServicesManager

所有已知实现类:
SimpleServicesManager

public interface ServicesManager
Manages services and service providers. Services are an interface specifying a list of methods that a provider must implement. Providers are implementations of these services. A provider can be queried from the services manager in order to use a service (if one is available). If multiple plugins register a service, then the service with the highest priority takes precedence.
  • 方法详细资料

    • register

      <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.
      类型参数:
      T - Provider
      参数:
      service - service class
      provider - provider to register
      plugin - plugin with the provider
      priority - priority of the provider
    • unregisterAll

      void unregisterAll(@NotNull @NotNull Plugin plugin)
      Unregister all the providers registered by a particular plugin.
      参数:
      plugin - The plugin
    • unregister

      void unregister(@NotNull @NotNull Class<?> service, @NotNull @NotNull Object provider)
      Unregister a particular provider for a particular service.
      参数:
      service - The service interface
      provider - The service provider implementation
    • unregister

      void unregister(@NotNull @NotNull Object provider)
      Unregister a particular provider.
      参数:
      provider - The service provider implementation
    • load

      @Nullable <T> T load(@NotNull @NotNull Class<T> service)
      Queries for a provider. This may return null if no provider has been registered for a service. The highest priority provider is returned.
      类型参数:
      T - The service interface
      参数:
      service - The service interface
      返回:
      provider or null
    • getRegistration

      @Nullable <T> @Nullable RegisteredServiceProvider<T> getRegistration(@NotNull @NotNull Class<T> service)
      Queries for a provider registration. This may return null if no provider has been registered for a service.
      类型参数:
      T - The service interface
      参数:
      service - The service interface
      返回:
      provider registration or null
    • getRegistrations

      Get registrations of providers for a plugin.
      参数:
      plugin - The plugin
      返回:
      provider registrations
    • getRegistrations

      Get registrations of providers for a service. The returned list is unmodifiable.
      类型参数:
      T - The service interface
      参数:
      service - The service interface
      返回:
      list of registrations
    • getKnownServices

      @NotNull @NotNull Collection<Class<?>> getKnownServices()
      Get a list of known services. A service is known if it has registered providers for it.
      返回:
      list of known services
    • isProvidedFor

      <T> boolean isProvidedFor(@NotNull @NotNull Class<T> service)
      Returns whether a provider has been registered for a service. Do not check this first only to call load(service) later, as that would be a non-thread safe situation.
      类型参数:
      T - service
      参数:
      service - service to check
      返回:
      whether there has been a registered provider