diff options
Diffstat (limited to 'azalea-client/src/client.rs')
| -rw-r--r-- | azalea-client/src/client.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 0cf01582..6b2dba57 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -87,6 +87,8 @@ pub struct Client { /// This is immutable; the server cannot change it. To get the username and /// skin the server chose for you, get your player from the [`TabList`] /// component. + /// + /// This as also available from the ECS as [`GameProfileComponent`]. pub profile: GameProfile, /// The entity for this client in the ECS. pub entity: Entity, @@ -580,6 +582,28 @@ impl Client { pub fn hunger(&self) -> Hunger { self.component::<Hunger>().to_owned() } + + /// Get the username of this client. + /// + /// This is a shortcut for + /// `bot.component::<GameProfileComponent>().name.clone()`. + pub fn username(&self) -> String { + self.component::<GameProfileComponent>().name.clone() + } + + /// Get the Minecraft UUID of this client. + /// + /// This is a shortcut for `bot.component::<GameProfileComponent>().uuid`. + pub fn uuid(&self) -> Uuid { + self.component::<GameProfileComponent>().uuid + } + + /// Get a map of player UUIDs to their information in the tab list. + /// + /// This is a shortcut for `bot.component::<TabList>().0`. + pub fn tab_list(&self) -> HashMap<Uuid, PlayerInfo> { + self.component::<TabList>().0 + } } /// A bundle for the components that are present on a local player that received |
