1use azalea_auth::game_profile::GameProfile;
2use azalea_chat::FormattedText;
3use azalea_core::game_type::GameMode;
4use azalea_entity::indexing::EntityUuidIndex;
5use bevy_ecs::{
6 event::EventReader,
7 system::{Commands, Res},
8};
9use uuid::Uuid;
10
11use crate::{packet_handling::game::AddPlayerEvent, GameProfileComponent};
12
13#[derive(Debug, Clone)]
15pub struct PlayerInfo {
16 pub profile: GameProfile,
19 pub uuid: Uuid,
21 pub gamemode: GameMode,
23 pub latency: i32,
26 pub display_name: Option<FormattedText>,
30}
31
32pub fn retroactively_add_game_profile_component(
36 mut commands: Commands,
37 mut events: EventReader<AddPlayerEvent>,
38 entity_uuid_index: Res<EntityUuidIndex>,
39) {
40 for event in events.read() {
41 if let Some(entity) = entity_uuid_index.get(&event.info.uuid) {
42 commands
43 .entity(entity)
44 .insert(GameProfileComponent(event.info.profile.clone()));
45 }
46 }
47}