https://github.com/breqdev/mcstatus
https://github.com/breqdev/mcstatus
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/breqdev/mcstatus
- Owner: breqdev
- Created: 2020-08-15T20:45:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-09-03T19:52:21.000Z (over 3 years ago)
- Last Synced: 2025-04-23T20:07:24.573Z (about 1 year ago)
- Language: JavaScript
- Size: 34.2 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# McStatus
**Live demo at [breq.dev/apps/mcstatus.html](https://breq.dev/apps/mcstatus.html)!**
A JavaScript library to embed a Minecraft server status readout.
Include the library:
```
```
Then, in your document, create elements for embeds with:
```
```
### Code structure
`mcstatus.js` loads a stylesheet into `` to style the embeds. It then loads a div complete with Minecraft server information into the DOM wherever it finds a `
`, 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](https://api.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. If you want to run your own relay, `pip3 install -r requirements.txt` and run the `relay.py` file.
I'm using Dinnerbone's awesome [Server Pinger](https://github.com/Dinnerbone/mcstatus) under the hood on the relay.
To change the style of the embed, just add a stylesheet that overrides the styles at [mcstatus.css](https://github.com/breqdev/mcstatus/blob/master/mcstatus.css).