Architecture - STEMMechanics/STEMCraft GitHub Wiki
Architecture
Runtime Shape
STEMCraft starts in STEMCraft.java and builds the runtime in four passes:
- Verifies Paper and the minimum supported Minecraft version (26.3)
- Bootstraps config and task infrastructure
- Instantiates core services and exposes them through
STEMCraftAPI - Scans and loads built-in features from
dev.stemcraft.feature - Scans and loads built-in commands and minigames
The plugin relies heavily on runtime registration rather than a static registry file.
Package Layout
api/src/main/java/dev/stemcraft/apiPublic interfaces, command abstractions, service contracts, minigame contracts, and shared modelsplugin/src/main/java/dev/stemcraft/serviceRuntime implementations of API servicesplugin/src/main/java/dev/stemcraft/featureOptional gameplay features that can register listeners, commands, and config-backed behaviorplugin/src/main/java/dev/stemcraft/commandStandalone commands loaded throughBaseCommandplugin/src/main/java/dev/stemcraft/minigameBuilt-in minigames and their command/config/runtime logicplugin/src/main/resourcesplugin.yml, locales, bundled defaults, and other plugin resourcesdocsOperator and developer documentation
Loading Model
Services
Services are instantiated directly in STEMCraft.java and attached to STEMCraftAPIImpl.
Important consequence:
- service availability is explicit
- the API surface is stable even when individual features are disabled
- services own durable resources such as database access, web endpoints, tab completion registries, and world management
Features
Features are discovered by scanning dev/stemcraft/feature for subclasses of BaseFeature.
Important consequence:
- adding a new feature usually means adding one class in that package
- enablement is config-driven through
BaseFeature - features can register commands, event listeners, scheduled tasks, and DB-backed state
Commands
Commands come from more than one place:
dev.stemcraft.commandviaBaseCommand- service-owned command classes such as
WorldCommand,ResourcePackCommand, andHubCommand - feature-owned direct registrations such as
/book,/coord,/speed, and/imenu - minigame command classes such as
/bridgeand/nightfall
Minigames
Minigames are discovered by scanning dev/stemcraft/minigame for subclasses of BaseMiniGame.
Each minigame typically owns:
- one command class
- one config helper
- one arena handler
- one arena record type
- the gameplay runtime implementation
Persistent State
STEMCraft uses two main persistence models:
- YAML config files for static configuration and operator-managed content
- SQLite for durable runtime state
Typical DB-backed systems include:
- punishments
- reports and moderation incidents
- first-join verification state
- player stats
- persistent scheduled tasks
- random first spawn state
- custom book state
- world change recording
Messaging and Locales
User-facing text is expected to go through the locale and message services rather than being hardcoded inline.
Main pieces:
LocaleServiceresolves keys and locale filesMessageServiceformats and dispatches messagesTokenProcessorapplies placeholder-like token expansion
Extension Guidance
When adding new behavior:
- put shared, reusable mechanics behind a service or API interface
- put optional gameplay behavior behind a feature
- keep command handling near the domain it controls
- prefer DB for runtime state and YAML for operator-authored configuration