debug option: check if version provided in config is correct

This commit is contained in:
Bixilon 2020-07-25 22:40:29 +02:00
parent 73f0b1b774
commit 727a3c8f92
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -60,7 +60,12 @@ public class PacketHandler {
if (version == -1) {
connection.setVersion(ProtocolVersion.byId(pkg.getResponse().getProtocolNumber()));
} else {
connection.setVersion(ProtocolVersion.byId(version));
ProtocolVersion protocolVersion = ProtocolVersion.byId(version);
if (protocolVersion == null) {
Log.fatal(String.format("In the config (debug.version) is a invalid version provided (version=%d). Exiting...", version));
System.exit(1);
}
connection.setVersion(protocolVersion);
}
}
Log.info(String.format("Status response received: %s/%s online. MotD: '%s'", pkg.getResponse().getPlayerOnline(), pkg.getResponse().getMaxPlayers(), pkg.getResponse().getMotd().getColoredMessage()));