This tiny gem implements the GameSpy query protocol to access pertinent real-time information hidden away inside your Minecraft server. You give Glowstone your server info, and Glowstone gives you:
- which players are currently online
- the base map name and default gamemode
- what plugins you're running
- even more stuff you probably don't care about!
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install glowstone
Glowstone's interface is super simple. Just instantiate yourself a new server object, like so:
my_server = Glowstone::Server.new "minecraft.tomheinan.com"
... and Glowstone will whip you up a server object full of all that delicious realtime data you've been craving:
=> #<Glowstone::Server:0x007ffe250099b8 @host="minecraft.tomheinan.com", @port=25565, @timeout=3, @socket=#<UDPSocket:fd 8>, @motd="Welcome to Arkenfall!", @gamemode="SMP", @version="1.2.5", @plugins=["CraftBukkit on Bukkit 1.2.5-R4.1-MCPC-SNAPSHOT: mod_MinecraftForge ForgeMod", "AdminCmd 6.0.1 (BUILD 01.06.2012 @ 10:41:06)", "WorldEdit 5.3", "ExtraBiomes XL ForgeMod", "WorldGuard 5.5.3", "PermissionsBukkit 1.6"], @map_name="arkenfall", @num_players=1, @max_players=16, @players=["tomheinan"]>
And that's all there is to it! No fancy bukkit plugins or server-side scripts required. If your server object is particularly long-lived and you find yourself wanting to refresh its data, just do
my_server.refresh and it'll pull down the latest information for you.
Help! I'm not receiving any data!
The first thing to do is make sure your server is set up to send it. Check your
server.properties file and make sure the
enable-query flag is set to
true. Then, make sure your server's firewall allows connections on UDP port
25565. If you've changed that value via the
query.port flag, then you'll also need to specify it when instantiating Glowstone, like so:
my_server = Glowstone::Server.new("myminecraftserver.com", 12345)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request