MW Server Control

Techniek
JavaScript · Node.js · Electron · Three.js
Team
Solo
Duur
3 weken (november 2026)
Resultaat
In gebruik met vrienden

Aanleiding Ik wilde met vrienden Minecraft spelen op een eigen server, gehost vanaf mijn laptop. Een kale server is een zwart venster waarin je commando's typt, en voor alles daaromheen (spelers beheren, back-ups, instellingen) moet je bestanden met de hand aanpassen. Ik wilde één overzichtelijk programma, in dezelfde stijl als dit portfolio.

Tech
JavaScript · Node.js · Electron · Three.js
Team
Solo
Duration
3 weeks (November 2026)
Result
In use with friends

Background I wanted to play Minecraft with friends on our own server, hosted from my laptop. A bare server is a black window where you type commands, and everything around it (managing players, backups, settings) means editing files by hand. I wanted one clear program, in the same style as this portfolio.

MW Server Control dashboard met status, adressen voor vrienden, CPU, geheugen en serversnelheid

Wat het is Een Windows-programma waarmee ik meerdere Minecraft-servers tegelijk host en beheer. Het draait in de systeembalk naast de klok, zodat de servers blijven lopen als het venster dicht is, en geeft een melding als er iemand joint of als een server crasht. Een nieuwe server maken is een formulier invullen: het programma downloadt de officiële server van Mojang, controleert de download en zet alles klaar. Mods installeer ik vanuit het programma zelf: het zet de server over op Fabric en haalt mods met alles wat ze nodig hebben van Modrinth. Op onze servers draaien nu onder andere graven voor je spullen als je doodgaat, snel verdwijnende bladeren en voicechat.

Mijn rol Alles: het idee, het ontwerp in de stijl van dit portfolio, de app zelf en het hosten. Dat laatste betekende Java installeren, de server instellen, port forwarding op mijn router regelen en alles testen met vrienden.

Uitgelicht

Een live kaart met spelers, zonder mods

Ik wilde een 3D-kaart van de wereld waarop je ziet waar iedereen is. De kaart zelf komt van BlueMap, maar een gewone Minecraft-server vertelt niet uit zichzelf waar spelers staan; daar heb je normaal een mod of plugin voor nodig.

De oplossing: het programma vraagt de server elke 2 seconden zelf om de positie, kijkrichting en dimensie van elke speler, met de gewone serverconsole. Die antwoorden worden uit de console gefilterd, zodat je ze niet ziet. Daarna zit het programma tussen de kaart en BlueMap in en geeft het de kaart de spelerposities in precies het formaat dat BlueMap verwacht. Dit gebeurt alleen terwijl iemand de kaart open heeft, zodat de server er verder niets van merkt.

De kaart heeft een live verbinding (server-sent events). Daarin zet mijn code elke 2 seconden de spelers, en de updates van BlueMap zelf stuur ik ongeschonden door:

function liveMapEvents(server, mapId, req, res) {
    res.writeHead(200, { "Content-Type": "text/event-stream", "Cache-Control": "no-store", Connection: "keep-alive" });
    const sendPlayers = () => {
        res.write(`event: player\ndata: ${JSON.stringify(server.livePlayers(mapId))}\n\n`);
    };
    sendPlayers();
    const timer = setInterval(sendPlayers, 2000);

    // BlueMap's events are forwarded whole (cut at the blank line between events), so they never mix with the panel's
    let buffer = "";
    const upstream = http.request({ host: "127.0.0.1", port: server.config.mapPort, path: `/maps/${mapId}/live/sse`, method: "GET" }, answer => {
        answer.setEncoding("utf8");
        answer.on("data", chunk => {
            buffer += chunk.replace(/\r\n/g, "\n");
            const events = buffer.split("\n\n");
            buffer = events.pop();
            for (const event of events) if (event.trim()) res.write(event + "\n\n");
        });
    });
    upstream.on("error", () => {});
    upstream.end();
    req.on("close", () => {
        clearInterval(timer);
        upstream.destroy();
    });
}

What it is A Windows program I use to host and manage several Minecraft servers at once. It runs in the system tray next to the clock, so the servers keep running when the window is closed, and it shows a notification when someone joins or a server crashes. Making a new server is filling in a form: the program downloads the official server from Mojang, checks the download and sets everything up. I install mods from within the program: it switches the server to Fabric and fetches mods, with everything they need, from Modrinth. Our servers now run, among others, graves that keep your items when you die, fast leaf decay and voice chat.

My role Everything: the idea, the design in the style of this portfolio, the app itself and the hosting. That last part meant installing Java, setting up the server, port forwarding on my router and testing it all with friends.

Highlight

A live map with players, without mods

I wanted a 3D map of the world that shows where everyone is. The map itself comes from BlueMap, but a normal Minecraft server doesn't share where players are; you usually need a mod or plugin for that.

The solution: every 2 seconds the program asks the server for each player's position, viewing direction and dimension, through the normal server console. Those answers are filtered out of the console, so you never see them. The program then sits between the map and BlueMap and gives the map the player positions in exactly the format BlueMap expects. This only happens while someone has the map open, so the server barely notices.

The map has a live connection (server-sent events). Every 2 seconds my code puts the players into it, and BlueMap's own updates are passed through untouched:

function liveMapEvents(server, mapId, req, res) {
    res.writeHead(200, { "Content-Type": "text/event-stream", "Cache-Control": "no-store", Connection: "keep-alive" });
    const sendPlayers = () => {
        res.write(`event: player\ndata: ${JSON.stringify(server.livePlayers(mapId))}\n\n`);
    };
    sendPlayers();
    const timer = setInterval(sendPlayers, 2000);

    // BlueMap's events are forwarded whole (cut at the blank line between events), so they never mix with the panel's
    let buffer = "";
    const upstream = http.request({ host: "127.0.0.1", port: server.config.mapPort, path: `/maps/${mapId}/live/sse`, method: "GET" }, answer => {
        answer.setEncoding("utf8");
        answer.on("data", chunk => {
            buffer += chunk.replace(/\r\n/g, "\n");
            const events = buffer.split("\n\n");
            buffer = events.pop();
            for (const event of events) if (event.trim()) res.write(event + "\n\n");
        });
    });
    upstream.on("error", () => {});
    upstream.end();
    req.on("close", () => {
        clearInterval(timer);
        upstream.destroy();
    });
}

Wat het kanWhat it can do

Uit de codeFrom the code

Lagmeter

De snelheid van de server meten

Elke 5 seconden vraagt het programma de server met het commando “tick query” hoe lang een tick gemiddeld duurt. Een tick mag 50 ms duren; daaronder draait de server op volle snelheid (20 TPS). Het antwoord verdwijnt uit de console, en de waarde gaat live naar het dashboard.

// "tick query" reports the average milliseconds per tick; 50 ms or less means the full 20 ticks per second
async pollTick() {
    if (this.state !== "online" || this.tickBusy) return;
    this.tickBusy = true;
    try {
        const text = await this.ask("tick query", /^Average time per tick: ([\d.,]+)ms/, /^(The game is |Target tick rate|Average time per tick|Percentiles)/);
        if (!text) return;
        const mspt = parseFloat(/([\d.,]+)ms/.exec(text)[1].replace(",", "."));
        const sample = { at: Date.now(), mspt, tps: Math.round(Math.min(20, 1000 / Math.max(mspt, 50)) * 10) / 10 };
        this.ticks.push(sample);
        if (this.ticks.length > 120) this.ticks.shift();
        this.broadcast("tick", sample);
    } finally {
        this.tickBusy = false;
    }
}
3D-spelers

Lopende spelers op de kaart

Op de kaart staat elke speler als 3D-model met zijn eigen skin, die ik bij Mojang ophaal. Uit hoe ver een speler sinds het vorige beeld is verschoven, reken ik zijn snelheid uit. Hoe sneller hij gaat, hoe verder en sneller zijn armen en benen zwaaien.

// Minecraft's yaw: 0 looks south (+z) and turns clockwise, so the model turns the other way round
body.rotation.y = -rotation.yaw * Math.PI / 180;

// Walking: the arms and legs swing faster and further the faster the marker moves
const position = marker.position.clone();
const speed = data.last ? Math.hypot(position.x - data.last.x, position.z - data.last.z) / Math.max(seconds, 0.001) : 0;
data.last = position;
data.speed = (data.speed || 0) * 0.85 + speed * 0.15;
const amount = Math.min(1, data.speed / 3);
if (amount > 0.02) { data.walk += seconds * (6 + data.speed * 2); moving = true; }
const swing = Math.sin(data.walk) * 0.9 * amount;
parts.rightLeg.rotation.x = swing;
parts.leftLeg.rotation.x = -swing;
parts.rightArm.rotation.x = -swing;
parts.leftArm.rotation.x = swing;
Lag meter

Measuring the server's speed

Every 5 seconds the program asks the server with the command “tick query” how long a tick takes on average. A tick may take 50 ms; below that the server runs at full speed (20 TPS). The answer is hidden from the console, and the value goes live to the dashboard.

// "tick query" reports the average milliseconds per tick; 50 ms or less means the full 20 ticks per second
async pollTick() {
    if (this.state !== "online" || this.tickBusy) return;
    this.tickBusy = true;
    try {
        const text = await this.ask("tick query", /^Average time per tick: ([\d.,]+)ms/, /^(The game is |Target tick rate|Average time per tick|Percentiles)/);
        if (!text) return;
        const mspt = parseFloat(/([\d.,]+)ms/.exec(text)[1].replace(",", "."));
        const sample = { at: Date.now(), mspt, tps: Math.round(Math.min(20, 1000 / Math.max(mspt, 50)) * 10) / 10 };
        this.ticks.push(sample);
        if (this.ticks.length > 120) this.ticks.shift();
        this.broadcast("tick", sample);
    } finally {
        this.tickBusy = false;
    }
}
3D players

Walking players on the map

Every player stands on the map as a 3D model with their own skin, which I fetch from Mojang. From how far a player moved since the previous frame I work out their speed. The faster they go, the further and faster their arms and legs swing.

// Minecraft's yaw: 0 looks south (+z) and turns clockwise, so the model turns the other way round
body.rotation.y = -rotation.yaw * Math.PI / 180;

// Walking: the arms and legs swing faster and further the faster the marker moves
const position = marker.position.clone();
const speed = data.last ? Math.hypot(position.x - data.last.x, position.z - data.last.z) / Math.max(seconds, 0.001) : 0;
data.last = position;
data.speed = (data.speed || 0) * 0.85 + speed * 0.15;
const amount = Math.min(1, data.speed / 3);
if (amount > 0.02) { data.walk += seconds * (6 + data.speed * 2); moving = true; }
const swing = Math.sin(data.walk) * 0.9 * amount;
parts.rightLeg.rotation.x = swing;
parts.leftLeg.rotation.x = -swing;
parts.rightArm.rotation.x = -swing;
parts.leftArm.rotation.x = swing;

Meer uit de codeMore from the code

ModsMods

Een mod installeren met alles wat hij nodig heeftInstalling a mod with everything it needs

Het programma vraagt Modrinth om de nieuwste Fabric-versie van een mod voor precies de Minecraft-versie van de server. Elke download wordt gecontroleerd met de SHA-1-checksum die Modrinth meegeeft, zodat een kapot bestand nooit in de server komt. Mods die de mod nodig heeft, installeert de functie zichzelf opnieuw voor; seen voorkomt dat twee mods die elkaar nodig hebben een eindeloze lus maken.

The program asks Modrinth for the newest Fabric build of a mod for exactly the server's Minecraft version. Every download is checked against the SHA-1 checksum Modrinth provides, so a broken file never ends up in the server. For the mods it needs, the function calls itself again; seen stops two mods that need each other from looping forever.

// Installs the newest Fabric build of a Modrinth project for this Minecraft version, plus the mods it needs
async installMod(projectId, asDependency = false, seen = new Set()) {
    if (!/^[\w-]{2,64}$/.test(projectId || "")) throw new UserError("Unknown mod");
    if (seen.has(projectId)) return [];
    seen.add(projectId);
    const version = this.config.lastKnownVersion;
    const index = this.readModIndex();
    if (Object.values(index).some(m => m.projectId === projectId)) return [];

    const project = await modrinth(`/project/${projectId}`);
    const versions = await modrinth(`/project/${projectId}/version?loaders=${encodeURIComponent('["fabric"]')}&game_versions=${encodeURIComponent(JSON.stringify([version]))}`);
    const pick = versions.find(v => v.version_type === "release") || versions[0];
    if (!pick) throw new UserError(`${project.title} has no version for Minecraft ${version} with Fabric yet`);
    const file = pick.files.find(f => f.primary) || pick.files[0];
    if (!/^[\w.+-]+\.jar$/.test(file.filename)) throw new Error(`Unexpected file name from Modrinth: ${file.filename}`);

    const response = await fetch(file.url, { headers: { "User-Agent": userAgent }, signal: AbortSignal.timeout(120000) });
    if (!response.ok) throw new Error(`Download of ${project.title} failed (${response.status})`);
    const data = Buffer.from(await response.arrayBuffer());
    if (crypto.createHash("sha1").update(data).digest("hex") !== file.hashes.sha1) throw new Error(`The download of ${project.title} is damaged (checksum does not match)`);
    await fsp.mkdir(this.modsDir, { recursive: true });
    await fsp.writeFile(path.join(this.modsDir, file.filename), data);

    const fresh = this.readModIndex();
    fresh[file.filename] = {
        projectId, slug: project.slug, title: project.title, description: project.description, icon: project.icon_url,
        version: pick.version_number, clientSide: project.client_side, dependency: asDependency, installedAt: Date.now()
    };
    this.writeModIndex(fresh);
    this.panelLog(`Mod installed: ${project.title} ${pick.version_number}${asDependency ? " (needed by another mod)" : ""}`);

    const installed = [project.title];
    for (const dep of pick.dependencies || []) {
        if (dep.dependency_type !== "required" || !dep.project_id) continue;
        installed.push(...await this.installMod(dep.project_id, true, seen));
    }
    return installed;
}
ServerberichtenServer messages

Een bericht als de server, in je eigen stijlA message as the server, in your own style

Met say krijg je in Minecraft alleen een grijze "[Server]". Daarom bouwt het programma zelf een tekstcomponent op uit de opgeslagen stijl (prefix, kleuren, vet en cursief) en stuurt die met tellraw of title naar iedereen, met een geluidje als je dat wilt.

With say, Minecraft only shows a grey "[Server]". So the program builds a text component from the saved style (prefix, colours, bold and italic) and sends it to everyone with tellraw or title, with a sound if you want one.

// Sends a styled message to everyone with tellraw (chat), or as a big title or text above the hotbar, instead of the plain "[Server]" of /say
serverMessage(text, mode, styleOverride) {
    this.requireOnline();
    const message = String(text || "").replace(/[\r\n]+/g, " ").trim();
    if (!message) throw new UserError("Type a message first");
    if (message.length > 256) throw new UserError("A message can be at most 256 characters");
    const s = styleOverride ? checkMessageStyle(styleOverride) : this.messageStyle();
    const how = mode || s.mode;
    if (!messageModes.includes(how)) throw new UserError("Unknown message type");

    const prefix = s.prefix ? [{ text: s.prefix, color: s.prefixColor, bold: s.prefixBold, italic: false }] : [];
    const separator = s.prefix && s.separator ? [{ text: s.separator, color: s.separatorColor, bold: false, italic: false }] : [];
    const body = { text: message, color: s.messageColor, bold: s.messageBold, italic: s.messageItalic };

    if (how === "chat") {
        this.sendCommand(`tellraw @a ${JSON.stringify(["", ...prefix, ...separator, body])}`, true);
    } else if (how === "actionbar") {
        this.sendCommand(`title @a actionbar ${JSON.stringify(["", ...prefix, ...separator, body])}`, true);
    } else {
        // Big title: the message in the middle of the screen, the prefix small underneath
        this.sendCommand("title @a times 10 70 20", true);
        this.sendCommand(`title @a subtitle ${JSON.stringify(["", ...prefix])}`, true);
        this.sendCommand(`title @a title ${JSON.stringify(body)}`, true);
    }
    if (s.sound) this.sendCommand("execute as @a at @s run playsound minecraft:block.note_block.pling master @s ~ ~ ~ 1 1.6", true);
    this.hideFor(/^No player was found$/, 1500);
    this.panelLog(`Message as the server (${how}): ${message}`);
    this.recordChat("Server", message);
}
3D-spelers3D players

Een Minecraft-skin op een 3D-blok leggenWrapping a Minecraft skin around a 3D block

Een Minecraft-skin is één plaatje van 64 bij 64 pixels, waarin elk lichaamsdeel uitgevouwen ligt. Deze functie maakt een blok voor bijvoorbeeld het hoofd of een arm en geeft elk van de zes vlakken het juiste stukje van de skin, in de volgorde die three.js gebruikt.

A Minecraft skin is a single 64 by 64 pixel image with every body part unfolded on it. This function makes a block for, say, the head or an arm and gives each of its six faces the right piece of the skin, in the order three.js uses.

// A box whose six faces show the right parts of a Minecraft skin.
// (u, v) is the top-left corner of the part in the skin; w, h, d are its width, height and depth in pixels.
function skinBox(w, h, d, u, v, inflate = 0) {
    const geometry = new THREE.BoxGeometry(w + inflate * 2, h + inflate * 2, d + inflate * 2);
    const uv = geometry.attributes.uv;
    const rect = (index, x, y, rw, rh, flipX = false) => {
        let x0 = x / 64, x1 = (x + rw) / 64;
        if (flipX) [x0, x1] = [x1, x0];
        const top = 1 - y / 64, bottom = 1 - (y + rh) / 64;
        uv.setXY(index * 4 + 0, x0, top);
        uv.setXY(index * 4 + 1, x1, top);
        uv.setXY(index * 4 + 2, x0, bottom);
        uv.setXY(index * 4 + 3, x1, bottom);
    };
    // Face order in three.js: +x, -x, +y, -y, +z, -z. The model faces +z, so -x is the player's right side.
    rect(0, u + d + w, v + d, d, h);          // +x: left side
    rect(1, u, v + d, d, h);                  // -x: right side
    rect(2, u + d, v, w, d);                  // +y: top
    rect(3, u + d + w, v, w, d);              // -y: bottom
    rect(4, u + d, v + d, w, h);              // +z: front
    rect(5, u + d + w + d, v + d, w, h);      // -z: back
    uv.needsUpdate = true;
    return geometry;
}
Back-upsBackups

Een back-up terwijl er gespeeld wordtA backup while people are playing

Als je de wereld kopieert terwijl de server erin schrijft, kan de kopie half zijn. Daarom zet het programma het opslaan eerst even uit, laat het de server alles wegschrijven en wacht het op "Saved the game". Pas dan wordt de wereld gekopieerd en daarna ingepakt als zip.

If you copy the world while the server is writing to it, the copy can be half-finished. So the program first pauses saving, has the server write everything out and waits for "Saved the game". Only then is the world copied and packed into a zip.

const pausedSaving = this.state === "online";
try {
    this.panelLog(`Backup started: ${zipName}`);
    // While online, saving is paused so the copy is not taken halfway through a write
    if (pausedSaving) {
        this.sendCommand("save-off", true);
        const saved = this.waitForLine(/^Saved the game/, 60000);
        this.sendCommand("save-all flush", true);
        await saved;
    }
    await fsp.cp(source, path.join(temp, folderName), { recursive: true, filter: src => path.basename(src) !== "session.lock" });

SchermenScreens

Klik op een afbeelding om hem op ware grootte te openen.

Click an image to open it at full size.

Live 3D-kaart van de Minecraft-wereld
Live kaart met BlueMapLive map with BlueMap
Spelersstatistieken met ranglijst en details per speler
Spelersstatistieken en ranglijstPlayer stats and leaderboard
Editor voor het servericoon en de gekleurde servertekst
Servericoon en gekleurde tekstServer icon and coloured text
Modspagina met geïnstalleerde mods en zoeken in Modrinth
Mods installeren vanuit ModrinthInstalling mods from Modrinth
Editor voor berichten als de server, met een voorbeeld in Minecraft-stijl
Berichten als de server, met voorbeeldServer messages, with a preview
Overzicht van alle servers
Meerdere servers tegelijkSeveral servers at once
Dashboard met status en lagmeter
Dashboard met lagmeterDashboard with lag meter

Terugblik Ik heb veel geleerd over hoe hosten echt werkt: poorten, port forwarding op de router, waarom elke server een eigen poort nodig heeft en wat er gebeurt als een proces onverwacht stopt. Het leukste was dat het meteen echt gebruikt werd: dezelfde avond speelde ik al met een vriend op de server.

Looking back I learned a lot about how hosting really works: ports, port forwarding on the router, why every server needs its own port and what happens when a process stops unexpectedly. The best part was that it was used for real straight away: that same evening I was already playing on the server with a friend.