Saturday, April 19, 2014

Introducing MineStat - A Minecraft Server Status Checker

My daughter and I have been playing Minecraft for the past year or so. After configuring a server of our own, I wanted a way to check its status. I initially wrote a Ruby class thinking our website would be a Rails application. I decided to port the code to Java and use JSP instead since I already had a Tomcat server running. I cleaned up the code this evening and figured I would release the source in case it could be of use to anyone else.

The project can be found on GitHub at https://github.com/ldilley/minestat. You can use the software to whip up a monitoring script that periodically polls multiple Minecraft servers or allow visitors of your website to see the status of your Minecraft server. Examples for C#, Java, PHP, and Ruby are below for demonstration purposes.

C# Example:


using System;

class Example
{
  public static void Main()
  {
    MineStat ms = new MineStat("cubekingdom.net", 25565);
    Console.WriteLine("Minecraft server status of {0} on port {1}:", ms.GetAddress(), ms.GetPort());
    if(ms.IsServerUp())
    {
      Console.WriteLine("Server is online running version {0} with {1} out of {2} players.", ms.GetVersion(), ms.GetCurrentPlayers(), ms.GetMaximumPlayers());
      Console.WriteLine("Message of the day: {0}", ms.GetMotd());
    }
    else
      Console.WriteLine("Server is offline!");
  }
}  


Java Example:


import org.devux.MineStat;  
   
class Example  
{  
  public static void main(String[] args)  
  {  
    MineStat ms = new MineStat("cubekingdom.net", 25565);    
    System.out.println("Minecraft server status of " + ms.getAddress() + " on port " + ms.getPort() + ":");  
    if(ms.isServerUp())  
    {  
      System.out.println("Server is online running version " + ms.getVersion() + " with " + ms.getCurrentPlayers() + " out of " + ms.getMaximumPlayers() + " players.");  
      System.out.println("Message of the day: " + ms.getMotd());  
    }  
    else  
      System.out.println("Server is offline!");  
  }  
}  


PHP Example:


<?php
require_once('minestat.php');

$ms = new MineStat("cubekingdom.net", 25565);
printf("Minecraft server status of %s on port %s:<br>", $ms->get_address(), $ms->get_port());
if($ms->is_online())
{
  printf("Server is online running version %s with %s out of %s players.<br>", $ms->get_version(), $ms->get_current_players(), $ms->get_max_players());
  printf("Message of the day: %s<br>", $ms->get_motd());
}
else
{
  printf("Server is offline!<br>");
}
?>


Ruby Example:


require_relative 'minestat'

ms = MineStat.new("cubekingdom.net", 25565)  
puts "Minecraft server status of #{ms.address} on port #{ms.port}:"
if ms.online
  puts "Server is online running version #{ms.version} with #{ms.current_players} out of #{ms.max_players} players."
  puts "Message of the day: #{ms.motd}"
else
  puts "Server is offline!"
end

Enjoy!

33 comments:

  1. Thanks for your review about minecraft server, get a cheap minecraft hosting in your budget with Cloudfrost Hosting.

    ReplyDelete
  2. I don't know that, It is new for my knowledge and It is good to know about the programming to check the status of minecraft. You can also take the high performance Minecraft Server Hosting services at best price.

    ReplyDelete
  3. You have shared such a nice experience about the status checking of Minecraft game and I always play this video game with my friends. I use Minecraft Hosting server for connecting with my friends and enjoyed a lot, you can try it if you want to play this game with your friends.

    ReplyDelete
  4. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head.
    I am highly impressed with your blog. It is very nicely explained.
    Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.

    ReplyDelete
  5. Lets play in minecraft with our cool skins, here you can find characters from games, books, anime etc. skins4minecraft.com

    ReplyDelete
  6. An advantage which people can really appreciate when playing them is simply getting the chance to relax following a monotonous days work. Games ought to be a simple and frequently mysterious experience that we as gamers can get a ton of prizes from.top minecraft servers

    ReplyDelete
  7. Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. g2a cashback code July 2018

    ReplyDelete
  8. Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject. fnaf world update 3

    ReplyDelete
  9. gambling club games like roulette and opening machines, military war games, PC games, different sorts of play among youngsters, and the rundown goes on.Unblocked Games Club

    ReplyDelete
  10. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. minecraft like games

    ReplyDelete
  11. A movement controller is one of the gaming fringe which is utilized to control the game accelerometers.https://unblockedgamesboo.weebly.com Correspondingly it tracks the movement.

    ReplyDelete
  12. This is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog..
    Mobdro APK iOS

    ReplyDelete
  13. This is an excellent post I seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post.
    Azar unlimited Gems APK

    ReplyDelete
  14. This is such a great resource that you are providing and you give it away for free.
    free ludo star download apk

    ReplyDelete
  15. Glad to chat your blog, I seem to be forward to more reliable articles and I think we all wish to thank so many good articles, blog to share with us.
    Gta 5 mobile apk free download

    ReplyDelete
  16. I really loved reading your blog. It was very well authored and easy to understand. Unlike other blogs I have read which are really not that good.Thanks alot!
    Showbox APK Donwnload

    ReplyDelete
  17. What a really awesome post this is. Truly, one of the best posts I've ever witnessed to see in my whole life. Wow, just keep it up.
    Planet Bomber APK Mod Download

    ReplyDelete
  18. However, those games which belong to the subset that feature violence, gore and antisocial behaviors have raised concern with parents,unblocked games for school educators, advocates and medical professionals.

    ReplyDelete
  19. Always so interesting to visit your site.What a great info, thank you for sharing. this will help me so much in my learning
    Download Sims 4 Mod Traits Latest Free

    ReplyDelete
  20. Writing with style and getting good compliments on the article is quite hard, to be honest.But you've done it so calmly and with so cool feeling and you've nailed the job. This article is possessed with style and I am giving good compliment. Best!
    Minecraft Story Mode APK season 1

    ReplyDelete
  21. GBWhatsapp apk Download Latest Version 2018. Download Latest GB Whatsapp for Use 2 Whatsapp in One Mobile.  GBWhatsApp App

    ReplyDelete
  22. I would like to thank you for thestruggle you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is transmissionits wings fastelrandomely.
    Gta 5 apk download for android

    ReplyDelete
  23. I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I Additionally large amounts of splendid encounters can be given to people when you wouldn't dare hoping anymore this is the way it's believed exceptionally
    splendid. People can appreciate the diversion when you want as this amusement needs.
    Download APK Editor PRO

    ReplyDelete
  24. thanks as a result an awful lot for sharing this amazing info! i am looking manage to peer more postsby you!
    how to make lenny face

    ReplyDelete
  25. Watch Here Online Pinoy Reply Shows Hd watch latest Pinoy Shows as well as GMA Network Tv episode of Pinoy lambingan
    Ang Probinsyano Pinoy

    ReplyDelete
  26. Watch Here Online Pinoy Reply Shows Hd watch latest Pinoy Shows as well as GMA Network Tv episode of Pinoy lambingan
    Ika-5 Utos Pinoy

    ReplyDelete
  27. Very good article thank you for sharing this useful information You casn See Here all Piony Tv Shows
    Halik Pinoy Replay

    ReplyDelete
  28. Thanks for sharing this blog, this blog is very helpful information for every one. You can Watch here Colors Tv Star plus and Zee Tv Episodes
    Watch Internet Wala Love Online

    ReplyDelete
  29. Watch Here Online Pinoy Reply Shows Hd watch latest Pinoy Shows as well as GMA Network Tv episode of Pinoy lambingan
    Ang Probinsyano Pinoy

    ReplyDelete
  30. Watch Here Indian Dramas Colors Tv Sony Tv StarPlus and Zee Tv Dramas Latest Episodes Online
    Yeh Rishta Kya Kehlata Hai Watch Online

    ReplyDelete
  31. If you set out to make me think today; mission accomplished! I really like your writing style and how you express your ideas. Thank you. Multiplayer Games

    ReplyDelete
  32. that is a to your liking tough article.i am pretty lots high-quality as well as your to your liking con.You codicil fact deeply likable to mitigation have sufficient share advice. hold it within the works. preserve blogging. trying to analyzing your adjoining declare.
    Clipacode

    ReplyDelete