Skip to content

WebGUI for Paper ​

A Paper server can run WebGUI as a plugin instead of a mod. Players keep the WebGUI client mod they already have, on Fabric or NeoForge, and see the same pages either way: the plugin speaks the same protocol, reads the same server.json and signs the same tokens. Added in WebGUI 2.3.0; hosted pages, placeholders, toasts and the death screen since 2.4.0, GUIs bound to entities since 2.5.0, screens in the world since 2.7.0.

Installing ​

  1. Download WebGUI (Paper plugin) from Modrinth. It is the same project as the mod; pick the version marked Paper.
  2. Put webgui-paper-<version>.jar in the server's plugins/ folder and start the server.
  3. Players install the WebGUI mod on their client, as for any WebGUI server.

One jar runs on every Paper release from 1.20.1 to 26.3, and on forks such as Purpur. It does not run on Spigot or on Folia.

The first start writes plugins/WebGUI/server.json with a fresh token secret, and plugins/WebGUI/web/ with a starter index.html (the main-menu page) and hud.html (the HUD shown on join).

Plugin and mod ​

PluginMod
Open a page as a GUI or a HUD✅✅
Signed tokens in page URLs✅✅
HUD on join, main-menu page✅✅
Events between page and server✅✅
Pages the server hosts (webgui://)✅ plugins/WebGUI/web/✅ config/webgui/web/
Placeholders✅ PlaceholderAPI✅ Text Placeholder API
Toasts sent from the server✅✅
Custom death screen✅✅
trustedCommandOrigins, requireClientMod, rate limiting✅✅
Update check✅✅
GUIs bound to entities✅✅
Screens in the world✅✅

Config ​

plugins/WebGUI/server.json has the same fields as the mod's config/webgui/server.json, with the same meaning. A file copied from a mod server works as it is.

json
{
  "autoHudUrl": "webgui://hud.html",
  "mainMenuUrl": "webgui://index.html",
  "deathScreenUrl": "webgui://death.html",
  "trustedCommandOrigins": ["https://shop.example.com"],
  "pagePlaceholders": ["player_name", "vault_eco_balance"]
}

Apply changes with /webgui reload. It also rescans plugins/WebGUI/web/, and pages players have open refresh with the new files.

Tokens are the same as the mod's, so token verification on your backend needs no change.

Placeholders ​

With PlaceholderAPI installed, placeholders in a page URL are filled in for the player the page opens for, and URL-encoded:

/webgui gui @p https://shop.example.com/?balance=%vault_eco_balance%&name=%player_name%

They are PlaceholderAPI's own, %expansion_params%, rather than the mod's %namespace:name%. Only placeholders of an installed expansion are replaced, so percent-encoding already in a URL (%20) is left alone.

A page asks for values with resolvePlaceholders, using the same ids:

ts
const values = await resolvePlaceholders(['player_name', 'vault_eco_balance'])

The server answers only for ids listed in pagePlaceholders; any other comes back null.

Death screen ​

deathScreenUrl replaces the vanilla death screen with a page. The page receives a webgui:death event with the same details as on the mod:

json
{
  "cause": "mob",
  "deathMessage": "Steve was slain by Zombie",
  "hardcore": false,
  "canRespawn": true,
  "killer": { "type": "mob", "name": "Zombie", "uuid": "…", "entityType": "minecraft:zombie" }
}

cause is the game's id for the kind of death (mob, player, fall, lava…), and killer.type is player, mob or environment. The page calls webgui.respawn() to respawn. With the immediate-respawn game rule on (doImmediateRespawn, immediate_respawn from 1.21.11) there is no death screen of either kind.

GUIs bound to entities ​

Right-clicking a bound entity, a villager or an armor stand say, opens its page:

/webgui bind entity @e[type=villager,limit=1,sort=nearest] "webgui://shop.html?npc={entity_id}" true

{entity_id}, {entity_type}, {player_name}, {player_uuid} and {player_language} in the URL are filled in at the click, and the page gets the entity as webgui.entity: { uuid, type, name, pos }, the same as on the mod. The last argument, true, stops the vanilla interaction, so the villager's trades do not open as well. /webgui unbind entity <entities> removes the binding.

The binding is stored on the entity itself, in its persistent data: it survives restarts and goes away with the entity. A mod server's entity_bindings.json is not read; bind the entities again on the Paper server.

Commands ​

CommandPermission
/webgui gui <targets> <url>webgui.command.gui
/webgui hud <targets> <url>webgui.command.hud
/webgui emit <targets> <event> <json>webgui.command.emit
/webgui toast <targets> "<title>" [description]webgui.command.toast
/webgui bind entity <entities> <url> [cancel_interaction]webgui.command.bind
/webgui unbind entity <entities>webgui.command.unbind
/webgui screen here|add|remove|list|url|resolution|transparent|interactive|emit ...webgui.command.screen
/webgui reloadwebgui.command.reload
/webgui status [targets]webgui.command.status

Targets are anything a vanilla command takes: a name, @a, @p[distance=..5]. A toast title with spaces goes in quotes: /webgui toast @a "Server restart" in 5 minutes. Every permission defaults to operators; webgui.command.* grants them all.

/webgui status lists each player, whether their client has WebGUI, and which WebGUI channels it registered. It is the first thing to check when a page does not open for someone.

Players without the mod ​

As on a mod server: a player whose client has no WebGUI, or an older one, is told so in chat once they join, and with requireClientMod they are refused instead. The plugin waits a few seconds after a player joins before deciding, because Paper learns a client's channels only after it is in.

For other plugins ​

Add depend: [WebGUI] to your plugin.yml and compile against the plugin jar (compileOnly).

java
import land.webgui.paper.PageEventReceivedEvent;
import land.webgui.paper.WebGUI;

// Open a page; false means the player's client has no WebGUI.
WebGUI.openGui(player, "webgui://shop.html");
WebGUI.openHud(player, "https://hud.example.com");

// Send an event the page receives with webgui.on('shop:balance', ...).
WebGUI.emitToPage(player, "shop:balance", "{\"coins\":120}");

// A toast, with an item for an icon.
WebGUI.showToast(player, "Purchase complete", "Diamond sword x1", "minecraft:diamond_sword");

// A screen in the world, centred on a location, and an event to its page.
WebGUI.putScreen(WebGUI.screen("lobby", location, "north", 3.2, 1.8, "webgui://screens/board.html"));
WebGUI.emitToScreen("lobby", "score", "{\"red\":3}");

// What pages send with webgui.postToGame({ channel: 'shop:buy', ... }).
@EventHandler
public void onPage(PageEventReceivedEvent event) {
    if (event.getChannel().equals("shop:buy")) {
        // event.getJson() is the page's data, as sent: parse it and trust none of it.
    }
}

Bindings: WebGUI.bindEntity(entity, urlTemplate, cancelInteraction), WebGUI.unbindEntity(entity) and WebGUI.getEntityBinding(entity). Also WebGUI.sendMainMenuUrl(player, url), WebGUI.hasWebGUI(player), WebGUI.protocolVersion() and WebGUI.maxUrlLength(). Call them from the main thread. PageEventReceivedEvent fires on the main thread, after the per-player limit pageEventsPerSecond.