Support multiple Minecraft protocol versions in lobby and probe logic

This commit is contained in:
timvisee
2021-11-23 01:12:50 +01:00
parent cf6bd526d9
commit b404ab0a87
20 changed files with 752 additions and 354 deletions

View File

@@ -115,6 +115,9 @@ impl Default for ClientState {
/// Client info, useful during connection handling.
#[derive(Debug, Clone, Default)]
pub struct ClientInfo {
/// Used protocol version.
pub protocol: Option<u32>,
/// Handshake as received from client.
pub handshake: Option<Handshake>,
@@ -126,4 +129,10 @@ impl ClientInfo {
pub fn empty() -> Self {
Self::default()
}
/// Get protocol version.
pub fn protocol(&self) -> Option<u32> {
self.protocol
.or_else(|| self.handshake.as_ref().map(|h| h.protocol_version as u32))
}
}