fix NPE when version isn't specified

This commit is contained in:
creeper123123321 2024-03-07 09:53:31 -03:00
parent 989f6b0d22
commit ed24df38a8

View File

@ -148,13 +148,13 @@ class WebLogin : WebState {
webClient.server.addressCallbacks[callback].complete( webClient.server.addressCallbacks[callback].complete(
AddressInfo( AddressInfo(
backVersion = obj["version"].asString.let { backVersion = obj["version"].asString.let {
val output = Ints.tryParse(it) val number = Ints.tryParse(it)
val protocol = if (output == null) { val protocol = if (number == null) {
ProtocolVersion.getClosest(it) ProtocolVersion.getClosest(it)
} else { } else {
ProtocolVersion.getProtocol(output) ProtocolVersion.getProtocol(number)
} } ?: AUTO
if (!protocol!!.isKnown) AUTO else protocol if (!protocol.isKnown) AUTO else protocol
}, },
backHostAndPort = HostAndPort.fromParts(obj["host"].asString, obj["port"].asInt), backHostAndPort = HostAndPort.fromParts(obj["host"].asString, obj["port"].asInt),
frontOnline = obj["frontOnline"].asString.toBooleanStrictOrNull(), frontOnline = obj["frontOnline"].asString.toBooleanStrictOrNull(),