fix -1 (disable viaversion) cases

This commit is contained in:
creeper123123321 2024-03-07 10:19:19 -03:00
parent ed24df38a8
commit 89f8295e0a
4 changed files with 7 additions and 16 deletions

View File

@ -117,10 +117,7 @@ public class AddressParser {
if (protocolId == null) {
protocol = ProtocolVersion.getClosest(arg.replace("_", "."));
} else {
final ProtocolVersion ver = ProtocolVersion.getProtocol(protocolId);
if (ver.isKnown()) {
protocol = ver;
}
protocol = ProtocolVersion.getProtocol(protocolId);
}
}
}

View File

@ -48,9 +48,8 @@ class HandshakeState : ConnectionState {
}
private fun handleNextState(handler: MinecraftHandler, packet: Handshake) {
ProtocolVersion.getProtocol(packet.protocolId).apply {
if (this.isKnown) handler.data.frontVer = this
}
handler.data.frontVer = ProtocolVersion.getProtocol(packet.protocolId)
when (packet.nextState.ordinal) {
1 -> handler.data.state = StatusState()
2 -> handler.data.state = LoginState()
@ -87,7 +86,7 @@ class HandshakeState : ConnectionState {
val addressFromWeb = VIAaaSConfig.hostName.any { parsed.serverAddress.equals(it, ignoreCase = true) }
handler.data.backServerVer = backProto
if (backProto == AUTO) handler.data.autoDetectProtocol = true
handler.data.autoDetectProtocol = backProto == AUTO
(handler.data.state as? LoginState)?.also {
it.frontOnline = frontOnline
it.backName = parsed.username

View File

@ -269,7 +269,7 @@ class LoginState : ConnectionState {
val info = AspirinServer.viaWebServer.requestAddressInfo(frontName).await()
backAddress = info.backHostAndPort
handler.data.backServerVer = info.backVersion
if (info.backVersion == AUTO) handler.data.autoDetectProtocol = true
handler.data.autoDetectProtocol = info.backVersion == AUTO
frontOnline = info.frontOnline
info.backName?.also { backName = info.backName }
}

View File

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