Skip to content
Ash edited this page Sep 28, 2015 · 2 revisions

Exploring AMCSAPI - Server List Ping

Chat isn't the only AMCSAPI can handle - you can also get the server list stats. These include the description/MOTD, version of the server (e.g. Bukkit 1.6, Glowstone 1.8 etc.), online and max player counts, the protocol number (and the game version number this represents) and the icon of the server. Here's how.

Setting up

First up, you should have a Server instance declared. (If you don't know how to do this, check the first tutorial.) It's probably a bad idea to start a chat connection on this instance, so don't do it. (You also don't need to call authenticate().)

Pinging the server

Doing the actual ping of the server is performed by running getServerInfo(). This sub returns a nice information class full of all the info you need. Let's take a look!

Note: This example assumes your Server instance is called mc.

Dim serverInfo As ServerInformation ''This is in the AMCSAPI.InfoStructures namespace, import if needed
serverInfo = mc.getServerInfo() ''This takes a while!

And that's it! You now have a ServerInformation class just waiting for you to get the info out of it.

Extracting the data

The ServerInformation class contains a bunch of variables and not much else. As you probably know, you can access variables like serverInfo.serverVersion. Here's a list of all of them:

  • serverVersionName (String) - The version as given by the server. Generally something like Spigot 1.7 or Sponge 1.8.
  • serverVersion (String) - The actual version of the server. In most cases, this is incorrect. Refer to the XML docs for more info.
  • protocolVersion (Integer) - The protocol number of the server. See here for a list of which one refers to which version.
  • onlinePlayers (Integer) - The number of online players, as reported by the server.
  • maxPlayers (Integer) - The maximum number of players, as reported by the server.
  • descriptionRaw (String) - The description/MOTD of the server. All formatting codes included.
  • iconRaw (String-Base64 Encoded) - The raw data of the icon, base64 encoded. Good luck decoding it!

Have fun pinging servers!

(P.S. If you need to have a chat connection to a server while pinging it (for some reason) just have two Server instances.)