Skip to content

Commit

Permalink
fix: handle error with server status info
Browse files Browse the repository at this point in the history
  • Loading branch information
crpmax committed Aug 5, 2022
1 parent 97efa9d commit b730759
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/main/java/me/creepermaxcz/mcbots/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,20 @@ public static void main(String[] args) throws Exception {
ServerInfo serverInfo = new ServerInfo(inetAddr);
serverInfo.requestInfo();
ServerStatusInfo statusInfo = serverInfo.getStatusInfo();
Log.info(
"Server version: "
+ statusInfo.getVersionInfo().getVersionName()
+ " (" + statusInfo.getVersionInfo().getProtocolVersion()
+ ")"
);
Log.info("Player Count: " + statusInfo.getPlayerInfo().getOnlinePlayers()
+ " / " + statusInfo.getPlayerInfo().getMaxPlayers());
Log.info();
if (statusInfo != null) {
Log.info(
"Server version: "
+ statusInfo.getVersionInfo().getVersionName()
+ " (" + statusInfo.getVersionInfo().getProtocolVersion()
+ ")"
);
Log.info("Player Count: " + statusInfo.getPlayerInfo().getOnlinePlayers()
+ " / " + statusInfo.getPlayerInfo().getMaxPlayers());
Log.info();
} else {
Log.warn("There was an error retrieving server status information. The server may be offline or running on a different version.");
}


new Thread(() -> {
for (int i = 0; i < botCount; i++) {
Expand Down

0 comments on commit b730759

Please sign in to comment.