Type-first access
Use type-first access when one implementation provides a service contract.serviceKey<T>() uses the Kotlin type as the key. This keeps
normal call sites free from string identifiers.
Class-based access
Use class-based overloads from non-reified code, Java-facing adapters, or code that already has aKClass.
serviceKey<MatchmakingService>().
Optional services
Useget or contains when a service is optional.
require for mandatory dependencies. It throws MissingServiceException
when no service is registered, so missing contracts fail during startup rather
than later gameplay.
Qualified keys
Use qualified keys only when several services implement the same public contract and consumers must select one explicitly.Module descriptors
Use the same service keys in module descriptors.requires and provides
describe service contracts; dependsOn declares ordering that has no service
contract.
Failure behavior
The default registry rejects duplicate registration for the same service key. If two implementations of one contract must exist, give each one a stable, qualified key.Duplicate service
Duplicate service
Registering the same key twice throws
DuplicateServiceException.Missing service
Missing service
registry.require<MatchmakingService>() throws MissingServiceException when
the service is not registered. Prefer require for mandatory module
dependencies.Next steps
- Read Runtime modules to declare service contracts in a Grounds Minestom module.
- Read Runtime composition to select provider-backed modules at startup.
