After last Christmas, I decided to buy myself a Pebble. I really wanted to write some kind of code for it. Since I was on break/had a ton of snow days, I set up a Feed the Beast (modded) Minecraft server to play with friends, running via Hamachi (a VPN).
The Pebble arrived around 6 pm on the first of three consecutive snow days leading up to the weekend. I proceded to stay up until 7:30 the next morning
working playing with it, mostly in a frustrated attempt to get SSH running on Windows via Cygwin. (Note to all: if you’d like to maintain your sanity, please do not do this. Linux exists for a reason.) One quick Ubuntu install later, I copied over the world files and had the Minecraft server running.
I wanted to be able to see who was currently logged into my Minecraft server whenever I glanced at my watch. This turned out to be fairly easy, with a few scripts and the MyData app for Pebble, but was complicated by my use of Hamachi.
Note that this guide explains how to do this for a server running Linux, only. These steps will not run on Windows or OSX servers (but probably could with a bit of coaxing).
You’ll need these three scripts on your server (click download zip, or copy paste them from here into text files).
Run your server on Linux
This has been documented very well elsewhere, so I’m not going to go into it. Google it, or feel free to drop me a line if you have problems. Make sure you know your IP, since you’ll need it later.
Forward your ports, or Hamachi
Again, this has been well-documented. Pick a port that you like and forward it in your router. I’ll be using 8000 here. If you’re using Hamachi, things are a little more complex. You’ll need to install Hamachi on your server (using either the command line version or the GUI), as well as on your phone.
Set up Python/bash scripts, Cron task, Minecraft Server
command means open a terminal and enter the command.
Don’t forget to download these files.
- Make a new folder in your server folder called mineservpoll.
- Unzip the three scripts and put them in this folder.
- Open starthttp.sh and change
/home/ian/server/mineservpollto the path of your folder.
- In that same file, change the port to whatever you like.
- Open statuscheck.sh and change
/home/ian/server/mineservpoll/status.py > /home/ian/server/mineservpoll/statusto your server folder’s path.
- Open status.py and change
localhost:25565to your server’s external IP (or Hamachi IP) and port.
- Open up your server.properties file, and set
enable-queryto true. Save/exit.
pip install mcstatusto get the necessary Python package.
crontab -e. Add the following lines, then save and exit.
- @reboot /path/to/starthttp.sh
- * * * * * /path/to/statuscheck.sh
- You might also consider adding @reboot
/path/to/your/startServer.shto your cron task.
- Reboot your computer.
Search for “MyData” on the Pebble app and load it onto your watch. Open the settings menu and type in the IP address of your server, followed by a colon and your port (eg 256.256.256.256:8000) and save your settings. If you’re using Hamachi, entert the Hamachi IPv4 address for the server, along with the port.
That’s it! Upon clicking the refresh button, your watch should display any currently-logged-in users.
Feel free to drop me a line if you run into any hiccups. Twitter’s best.