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:
parent
2b6103e6d9
commit
0b4c56b803
|
@ -79,6 +79,7 @@ pub struct Server {
|
||||||
target_info: target::Info,
|
target_info: target::Info,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct PlayerInfo {
|
pub struct PlayerInfo {
|
||||||
name: String,
|
name: String,
|
||||||
uuid: protocol::UUID,
|
uuid: protocol::UUID,
|
||||||
|
@ -1396,6 +1397,18 @@ impl Server {
|
||||||
&mut self,
|
&mut self,
|
||||||
spawn: packet::play::clientbound::SpawnPlayer_i32_HeldItem_String,
|
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(
|
self.on_player_spawn(
|
||||||
spawn.entity_id.0,
|
spawn.entity_id.0,
|
||||||
protocol::UUID::from_str(&spawn.uuid).unwrap(),
|
protocol::UUID::from_str(&spawn.uuid).unwrap(),
|
||||||
|
@ -1669,7 +1682,23 @@ impl Server {
|
||||||
&mut self,
|
&mut self,
|
||||||
_player_info: packet::play::clientbound::PlayerInfo_String,
|
_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) {
|
fn on_player_info(&mut self, player_info: packet::play::clientbound::PlayerInfo) {
|
||||||
|
|
Loading…
Reference in New Issue