mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
Add function to get message sender's UUID (#56)
* Add uuid function for chat messages * Does this please you, clippy?
This commit is contained in:
parent
b86a89fa1e
commit
54e00eb3df
2 changed files with 11 additions and 1 deletions
|
@ -26,5 +26,5 @@ parking_lot = {version = "^0.12.1", features = ["deadlock_detection"]}
|
|||
regex = "1.7.0"
|
||||
thiserror = "^1.0.34"
|
||||
tokio = {version = "^1.23.1", features = ["sync"]}
|
||||
typemap_rev = "0.2.0"
|
||||
typemap_rev = "0.3.0"
|
||||
uuid = "^1.1.2"
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue