Interface ServiceManager


public interface ServiceManager
A service manager that allows plugins to share functionalities painlessly.
  • Method Details

    • register

      default <T> void register(MindustryPlugin plugin, Class<T> service, T instance, Priority priority)
      Registers the instance as one of the available implementations for the service.
      Type Parameters:
      T - the type of the service
      Parameters:
      plugin - the plugin
      service - the service
      instance - the instance
      priority - the priority
    • register

      <T> void register(MindustryPlugin plugin, TypeToken<T> service, T instance, Priority priority)
      Registers the instance as one of the available implementations for the service.
      Type Parameters:
      T - the type of the service
      Parameters:
      plugin - the plugin
      service - the service
      instance - the instance
      priority - the priority
    • provide

      default <T> Optional<T> provide(Class<T> service)
      Provides a service of the given type.
      Type Parameters:
      T - the type of the service
      Parameters:
      service - the service
      Returns:
      an implementation of the service or an empty optional if no implementation is found
    • provide

      default <T> Optional<T> provide(TypeToken<T> service)
      Provides an instance of the given service.
      Type Parameters:
      T - the type of the service
      Parameters:
      service - the service
      Returns:
      an implementation of the service or an empty optional if no implementation is found
    • getProviders

      default <T> List<ServiceProvider<T>> getProviders(Class<T> service)
      Returns all providers of the given service.
      Type Parameters:
      T - the type of the service
      Parameters:
      service - the service
      Returns:
      the providers
    • getProviders

      <T> List<ServiceProvider<T>> getProviders(TypeToken<T> service)
      Returns all providers of the given service.
      Type Parameters:
      T - the type of the service
      Parameters:
      service - the service
      Returns:
      the providers