1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use azalea_auth::game_profile::GameProfile;
use azalea_chat::FormattedText;
use azalea_core::GameType;
use azalea_ecs::{
event::EventReader,
system::{Commands, Res},
};
use azalea_world::entity::EntityInfos;
use uuid::Uuid;
use crate::{packet_handling::AddPlayerEvent, GameProfileComponent};
#[derive(Debug, Clone)]
pub struct PlayerInfo {
pub profile: GameProfile,
pub uuid: Uuid,
pub gamemode: GameType,
pub latency: i32,
pub display_name: Option<FormattedText>,
}
pub fn retroactively_add_game_profile_component(
mut commands: Commands,
mut events: EventReader<AddPlayerEvent>,
entity_infos: Res<EntityInfos>,
) {
for event in events.iter() {
if let Some(entity) = entity_infos.get_entity_by_uuid(&event.info.uuid) {
commands
.entity(entity)
.insert(GameProfileComponent(event.info.profile.clone()));
}
}
}