Game components
A Minekube game is an Effect UI component, mounted in Paper by the Minekube plugin. Its state changes only through messages, and everything it wants to happen in the world is data, a Command, until the server half carries it out. The same shape runs a proxy bundle on Velocity and a bot in a client.
The parts
Section titled “The parts”| Part | What it is |
|---|---|
| Model | The game’s state, with a Schema. |
| Messages | What happened, as a tagged union with Schemas: a player clicked a sign, a round ended, a Command answered. |
update |
One handler per message. It returns the next Model and the Commands to run, and never calls Paper or waits. |
| Commands | What should happen, such as launching a player. Declared in the rules, implemented in the server half with Paper calls. |
| Subscriptions | Where messages come from: Paper events with Paper.event, and server commands with Paper.command. |
| Children | Other components the game renders, each with its own Model, such as one per arena or per player. |
A game is therefore a tree of components: the game at the root, and children for the parts that have their own state and their own lifetime.
Rules and the server half
Section titled “Rules and the server half”A game has two halves, in two files.
- The rules are the Model, the messages,
updateand the Command declarations. They import no Java, so they run in Bun. - The server half turns Paper events into messages, implements each Command with Paper’s real API, and mounts the component with
Paper.mount.
Because the rules decide without touching the server, the same message always gives the same Model and the same Commands. That is what makes a recorded session replayable months later, and what lets Stories test the rules in milliseconds. See Session recordings.
Commands and server commands
Section titled “Commands and server commands”Two different things share the word.
- A Command is an effect the rules ask for. A silent Command acts on the world. A Command with a
successanswers with a message, and one with anerrordeclares a failure the rules can react to. A Command runs as long as its Effect, so a particle trail that repeats for a second is one Command. - A server command, such as
/browse, is something a player types.Paper.commandmakes it one of the server’s own commands while the game runs, with suggestions as players type, and turns each use into a message.
A scope per revision
Section titled “A scope per revision”Everything a loaded bundle starts, it starts inside its scope: listeners, timers, fibers, running Commands and its server commands. When the runtime replaces or uninstalls the bundle, the scope closes and all of it ends. There is no disable hook to forget, and nothing of the previous code keeps running, which is what makes live swap safe.
The world is not in the scope. Blocks and entities belong to the server, so a game creates them in a way that tolerates finding them already there, and pairs anything it must remove with its removal.
Children are failure boundaries
Section titled “Children are failure boundaries”A bug in a running game, such as a Java exception in a Command, fails the component it happened in.
- A failed child shows its fallback, its parent hears of it, and the rest of the game keeps running. Give each arena or player its own child, so that one player’s bug does not restart everyone’s round.
- The game itself is a child too. The runtime mounts it under its own small component, the Supervisor, which starts a failed game over from its first Model and reports the failure. A game that keeps failing stays off until its next revision, so a crash at start cannot loop on the server thread. Limits gives the threshold.
Why components
Section titled “Why components”Minecraft games are full of state that changes on events, and plugins usually scatter that state across listeners. A component gathers it in one Model, with one place where it changes. The result is code that a person or a coding agent can read in one file, test without a server, and replay from a real session.
What a game is not
Section titled “What a game is not”- Not a Paper plugin. It has no plugin class, no
onEnableand no jar of its own. It is a bundle that the Minekube plugin runs. - Not a wrapper over Paper. The server half calls Paper’s own classes, typed from the server’s jars.
- Not required to be a component.
Paper.makeruns any Effect program as a game, but only components are recorded and replayable.
Related
Section titled “Related”- Games as Effect components: the programming model in depth.
- Game structure: the rules and the server half in code, with events, lifetime and failures.
- Proxy bundles: the same model on Velocity.
Was this helpful?
Thanks for the feedback.