Skip to content
Get started

The real API, not a wrapper

View as Markdown

A Minekube game calls Paper’s own objects: server.getPlayer(...), event.setCancelled(true), player.sendActionBar(...). There is no Minekube API for players, blocks or menus in between. The contract is the server’s API itself, typed from the server’s jars.

The first version translated every Paper call into its own JSON: an OpenAPI contract, one HTTP call per action, a converter per Java type. Every new type and every new feature then needed new code on the JVM, written by us. A game could not cancel an event in the tick it happened, and it could not implement a Java interface. An earlier client test driver built the same way grew hand-written bindings for every Minecraft version and every capability.

A contract layer over the real API forces feature code into the layer. So there is none.

  • Games call the API directly. The runtime hosts the game in GraalJS inside the server, so a call is a call, in the same tick, on the same objects.
  • Types come from the jars. A generator reads every public class of Paper, Adventure, Brigadier and JOML by reflection, and nullability from the bytecode’s annotations. You get Paper’s names, overloads, nullability and @deprecated marks, and Java.type("org.bukkit.Particle$DustOptions") is typed. The generator runs in the runtime when the server starts, on that server’s own jars, and mk dev . copies the result into your project. No package ships these types: they carry names from code we do not own, and they always match the server you run.
  • What Java obliges you to handle is in the types. A method that declares checked exceptions, or hands you something to close, cannot be called directly; only Jvm.attempt and Jvm.acquire get through, as Effects. See TypeScript and Effect.
  • The generator writes data, not logic. Schemas for Java values (a java.util.UUID as a checked, branded string, every enum as a union of its constants, every registry type such as Sound or Biome as its key) and a table of conversions. The code that converts values at the boundary is ordinary, typed SDK code that reads the table.

Paper code gets Paper’s types and Velocity code gets Velocity’s, each generated from that platform’s jars. There is no common layer across platforms: a Minestom game would get Minestom’s types. Reuse between platforms is a choice you make in TypeScript, not something we put between you and the server. See Platforms.

The types are also those of one version. The Paper runtime is one jar for Paper 1.21 and newer: it is built against the oldest supported API and runs unchanged on newer servers. What changes with the version is only the types, so each project uses the types of the server it targets.

  • No feature needs JVM code. A new game, event, menu, command or world feature changes nothing in the runtime. If something cannot be done through the server’s API from TypeScript, that is a gap in the runtime, closed once for every game.
  • Same-tick control. A handler runs inside Paper’s own dispatch, so it can cancel or change the event before Paper continues.
  • Java interfaces from JS. A JS function goes where Java expects a Runnable, a Consumer or a Brigadier Command.
  • Server updates cost nothing. A new Paper build brings new types, generated from its jars. Nothing in between has to follow.
  • Agents read the types like any library. Your coding agent searches paper.d.ts the way it searches any dependency, and the strict check tells it when it guessed wrong.
  • A game sees the server’s whole public JVM, like a plugin does. That is right for your own code on your own server. Running other people’s games safely needs an allowlist per installation, resource limits and separate contexts; that is planned, as permissions rather than code generation.
  • Some parameter names are missing. Paper’s API jar has none, so they read arg0, arg1. They can come from the sources jar.
  • Games are tied to their platform. A Paper game does not run on Velocity. That is the point: each platform keeps its full API.

Was this helpful?