diff options
Diffstat (limited to 'azalea-client/src')
| -rwxr-xr-x | azalea-client/src/chat.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/azalea-client/src/chat.rs b/azalea-client/src/chat.rs index fa88daf7..44ad8a71 100755 --- a/azalea-client/src/chat.rs +++ b/azalea-client/src/chat.rs @@ -12,6 +12,7 @@ use std::{ sync::Arc, time::{SystemTime, UNIX_EPOCH}, }; +use uuid::Uuid; /// A chat packet, either a system message or a chat message. #[derive(Debug, Clone, PartialEq)] @@ -72,6 +73,15 @@ impl ChatPacket { self.split_sender_and_content().0 } + /// Get the UUID of the sender of the message. If it's not a + /// player-sent chat message, this will be None. + pub fn uuid(&self) -> Option<Uuid> { + match self { + ChatPacket::System(_) => return None, + ChatPacket::Player(m) => return Some(m.sender), + } + } + /// Get the content part of the message as a string. This does not preserve /// formatting codes. If it's not a player-sent chat message or the sender /// couldn't be determined, this will contain the entire message. |
