core-api
The module contract from Architecture › Rule 1.
Every module depends on it; it depends on nothing but Minestom (compile-only)
and SLF4J. Source in libs/core-api/, package com.shatterveil.api.
Types
| Type | Role |
|---|---|
ShatterveilModule | The one entry class per module: manifest(), onEnable(ctx), optional onDisable(ctx) |
ModuleManifest | id, name, version, description, dependencies, SecurityClass, kernel flag. Built with ModuleManifest.builder(id)…build(); validated on construction (ids match [a-z][a-z0-9]*(-[a-z0-9]+)*) |
SecurityClass | CRITICAL or STANDARD — see Architecture › Rule 4 |
ModuleContext | The only way a module registers listeners (its own child EventNode), commands, tasks and published services. Records everything; undoAll() reverses it. Also exposes log(), logger(), services(), onlinePlayers() and findPlayer(name) |
ModuleHost | The server hooks a context registers on; implemented by the launcher (ServerProcessModuleHost) and by the test helpers. Modules never use it directly |
ServiceRegistry | Modules publish (publish(type, service, owner)) and find (find(type), require(type)) services instead of importing each other. owner(type) says which module published one |
ModuleDirectory | Read-only view of every loaded module and its state, for /module and the admin API |
ServerInfo | Name, version and start time, for /v1/status |
CommandDoc | Description, usage lines, examples and permission for one command; the commands builder produces one and refuses incomplete ones |
log.ModuleLog, log.LogEvent, log.EventLog | The logging face a module sees: ctx.log().audit(action)…, .game(action)…, .system(action)…. Categories AUDIT / GAME / SYSTEM; severities INFO / WARN / ERROR / ALERT. The pipeline behind it is the log library |
Discovery
Modules are discovered with ServiceLoader; each module jar ships a
META-INF/services/com.shatterveil.api.ShatterveilModule file naming its
entry class. The launcher loads every module on the classpath, resolves
dependency order and enables them.
A minimal module
public final class WelcomeModule implements ShatterveilModule {
@Override
public ModuleManifest manifest() {
return ModuleManifest.builder("welcome")
.name("Welcome")
.version("0.1.0")
.description("Welcome title, MOTD and server icon.")
.securityClass(SecurityClass.STANDARD)
.build();
}
@Override
public void onEnable(ModuleContext ctx) {
ctx.listen(PlayerSpawnEvent.class, event -> { /* ... */ });
// commands: Commands.define("...")...register(ctx)
// tasks: ctx.scheduleTask(...)
}
// onDisable is optional: the context undoes every registration anyway.
}
The real thing is the welcome module.