1.7.10: populate player info on spawn, fixes #141 (#485)

PlayerInfo post-1.7.10 has the UUID, so it populates the self.players map,
in 1.7.10 there is only enough information for the client <tab> list. To fix
this, instead populate self.players in SpawnPlayer, for the 1.7.10 variant.

Fixes player name tags showing as "MISSING" on 1.7.10 servers.
This commit is contained in:
iceiix 2021-01-18 13:53:09 -08:00 committed by GitHub
parent 2b6103e6d9
commit 0b4c56b803
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 1 deletions

View File

@ -79,6 +79,7 @@ pub struct Server {
target_info: target::Info,
}
#[derive(Debug)]
pub struct PlayerInfo {
name: String,
uuid: protocol::UUID,
@ -1396,6 +1397,18 @@ impl Server {
&mut self,
spawn: packet::play::clientbound::SpawnPlayer_i32_HeldItem_String,
) {
// 1.7.10: populate the player list here, since we only now know the UUID
let uuid = protocol::UUID::from_str(&spawn.uuid).unwrap();
self.players.entry(uuid.clone()).or_insert(PlayerInfo {
name: spawn.name.clone(),
uuid,
skin_url: None,
display_name: None,
ping: 0, // TODO: don't overwrite from PlayerInfo_String
gamemode: Gamemode::from_int(0),
});
self.on_player_spawn(
spawn.entity_id.0,
protocol::UUID::from_str(&spawn.uuid).unwrap(),
@ -1669,7 +1682,23 @@ impl Server {
&mut self,
_player_info: packet::play::clientbound::PlayerInfo_String,
) {
// TODO: support PlayerInfo_String for 1.7
// TODO: track online players, for 1.7.10 - this is for the <tab> online player list
// self.players in 1.7.10 will be only spawned players (within client range)
/*
if player_info.online {
self.players.entry(uuid.clone()).or_insert(PlayerInfo {
name: player_info.name.clone(),
uuid,
skin_url: None,
display_name: None,
ping: player_info.ping as i32,
gamemode: Gamemode::from_int(0),
});
} else {
self.players.remove(&uuid);
}
*/
}
fn on_player_info(&mut self, player_info: packet::play::clientbound::PlayerInfo) {