McStatus.js

A JavaScript library to embed information about a Minecraft server into a website.

Link to this section Overview

McStatus.js is a JavaScript library and API backend to embed a Minecraft server status readout.

Link to this section Motivation

I wanted to be able to check who was online on my Minecraft server without having to join. I also wanted a project where I could improve my understanding of JavaScript, the DOM, and web technologies in general.

Link to this section Technical Details

mcstatus.js loads a div complete with Minecraft server information into the DOM wherever it finds a <div class="mc-status">, using the data-mc-server attr to set the server IP. The status protocol for Minecraft servers uses raw TCP sockets, so a pure-JS server query-er isn't possible. There are a lot of existing Minecraft server status tools, like mcsrvstat.us, but they don't have a CORS header set, so they couldn't be used from JavaScript. So, I implemented my own at https://mcstatus.breq.dev/ with the bare minimum API for this project to work. I'm using Dinnerbone's Server Pinger under the hood for this.

Link to this section Results

It pretty much does everything I wanted it to do, and working on the project definitely gave me a better understanding of how to style websites using CSS. I didn't really end up using the CSS/JS part for anything, but I did use the server component for Breqbot's Minecraft server functionality.