PlayerInfo has signature data in 1.19

Since this is deep inside a complex packet structure, conditionalize
https://wiki.vg/index.php?title=Protocol&oldid=17706#Player_Info
https://wiki.vg/index.php?title=Protocol&oldid=17499#Player_Info
This commit is contained in:
ice_iix 2022-08-07 17:54:03 -07:00
parent 773e35cac6
commit e8dd8f0d93
2 changed files with 33 additions and 9 deletions

View File

@ -3071,19 +3071,37 @@ impl Serializable for PlayerInfoData {
}
props.push(prop);
}
let gamemode: VarInt = Serializable::read_from(buf)?;
let ping: VarInt = Serializable::read_from(buf)?;
let display: Option<format::Component> = if bool::read_from(buf)? {
Some(Serializable::read_from(buf)?)
} else {
None
};
let mut timestamp: Option<u64> = None;
let mut public_key: Option<LenPrefixedBytes<VarInt>> = None;
let mut signature: Option<LenPrefixedBytes<VarInt>> = None;
if super::current_protocol_version() >= 759 {
let has_sig_data: bool = Serializable::read_from(buf)?;
if has_sig_data {
timestamp = Some(Serializable::read_from(buf)?);
public_key = Some(Serializable::read_from(buf)?);
signature = Some(Serializable::read_from(buf)?);
}
}
let p = PlayerDetail::Add {
uuid,
name,
properties: props,
gamemode: Serializable::read_from(buf)?,
ping: Serializable::read_from(buf)?,
display: {
if bool::read_from(buf)? {
Some(Serializable::read_from(buf)?)
} else {
None
}
},
gamemode,
ping,
display,
timestamp,
public_key,
signature,
};
m.players.push(p);
}
@ -3135,6 +3153,9 @@ pub enum PlayerDetail {
gamemode: VarInt,
ping: VarInt,
display: Option<format::Component>,
timestamp: Option<u64>,
public_key: Option<LenPrefixedBytes<VarInt>>,
signature: Option<LenPrefixedBytes<VarInt>>,
},
UpdateGamemode {
uuid: UUID,

View File

@ -1900,6 +1900,9 @@ impl Server {
display,
gamemode,
ping,
timestamp: _,
public_key: _,
signature: _,
} => {
let info = self.players.entry(uuid.clone()).or_insert(PlayerInfo {
name: name.clone(),