Skip to content

Instantly share code, notes, and snippets.

@njb-said
Last active August 29, 2015 14:22
Show Gist options
  • Save njb-said/b550b8555aa0948b1067 to your computer and use it in GitHub Desktop.
Save njb-said/b550b8555aa0948b1067 to your computer and use it in GitHub Desktop.
ping thing
@EventHandler
public void onPing(ProxyPingEvent e) {
ServerPing old = e.getResponse();
ServerPing reply = new ServerPing();
// this playerCount variable is not defined because you can get it yourself.. (or if you use redis/mysql to store online player count)
reply.setPlayers(new ServerPing.Players(playerCount + 1, playerCount, old.getPlayers().getSample()));
reply.setDescription("whatever motd you want");
reply.setFavicon(favicon);
reply.setVersion(old.getVersion());
e.setResponse(reply);
}
@njb-said
Copy link
Author

njb-said commented Jun 8, 2015

You probably should register intent as this is an async event, but this is a yolo gist 💥

Edit favicon and playerCount are not defined as variables because you might want to change them or get them from a database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment