Interface ServiceManager
public interface ServiceManager
A service manager that allows plugins to share functionalities painlessly.
-
Method Summary
Modifier and TypeMethodDescription<T> List<ServiceProvider<T>>getProviders(TypeToken<T> service) Returns all providers of the given service.default <T> List<ServiceProvider<T>>getProviders(Class<T> service) Returns all providers of the given service.default <T> Optional<T>Provides an instance of the givenservice.default <T> Optional<T>Provides a service of the given type.<T> voidregister(MindustryPlugin plugin, TypeToken<T> service, T instance, Priority priority) Registers theinstanceas one of the available implementations for theservice.default <T> voidregister(MindustryPlugin plugin, Class<T> service, T instance, Priority priority) Registers theinstanceas one of the available implementations for theservice.
-
Method Details
-
register
Registers theinstanceas one of the available implementations for theservice.- Type Parameters:
T- the type of the service- Parameters:
plugin- the pluginservice- the serviceinstance- the instancepriority- the priority
-
register
Registers theinstanceas one of the available implementations for theservice.- Type Parameters:
T- the type of the service- Parameters:
plugin- the pluginservice- the serviceinstance- the instancepriority- the priority
-
provide
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
Provides an instance of the givenservice.- 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
Returns all providers of the given service.- Type Parameters:
T- the type of the service- Parameters:
service- the service- Returns:
- the providers
-
getProviders
Returns all providers of the given service.- Type Parameters:
T- the type of the service- Parameters:
service- the service- Returns:
- the providers
-