Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. public static void status(Session s, String HOST, int PORT) {
  2.  
  3. MinecraftProtocol protocol = new MinecraftProtocol(SubProtocol.STATUS);
  4. Client client = new Client(HOST, PORT, protocol, new TcpSessionFactory(
  5. Proxy.NO_PROXY));
  6. client.getSession().setFlag(MinecraftConstants.AUTH_PROXY_KEY,
  7. Proxy.NO_PROXY);
  8. client.getSession().setFlag(MinecraftConstants.SERVER_INFO_HANDLER_KEY,
  9. new ServerInfoHandler() {
  10. @Override
  11. public void handle(Session session, ServerStatusInfo info) {
  12. Util.sendMsg(
  13. s,
  14. Config.PingYes
  15. + "&8[&a"
  16. + info.getDescription()
  17. + " &8| "
  18. + "&a"
  19. + info.getPlayerInfo()
  20. .getOnlinePlayers() + "&8/"
  21. + "&a"
  22. + info.getPlayerInfo().getMaxPlayers()
  23. + "&8]");
  24. }
  25. });
  26.  
  27. client.getSession().setFlag(
  28. MinecraftConstants.SERVER_PING_TIME_HANDLER_KEY,
  29. new ServerPingTimeHandler() {
  30. @Override
  31. public void handle(Session session, long pingTime) {
  32. Util.sendMsg(s, Config.Ping + pingTime);
  33. }
  34. });
  35.  
  36. client.getSession().connect();
  37. while (client.getSession().isConnected()) {
  38. try {
  39. Thread.sleep(5);
  40. } catch (InterruptedException e) {
  41. e.printStackTrace();
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement