aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEightFactorial <murphkev000@gmail.com>2023-01-14 19:56:09 -0800
committerGitHub <noreply@github.com>2023-01-14 21:56:09 -0600
commit54e00eb3df12262a0b31c11600acedf1544ac4fb (patch)
treeb38f4b7db0044498d6903c8fd56438784f6dbab1
parentb86a89fa1ea059b566217991a656b31bf6841ba0 (diff)
downloadazalea-drasl-54e00eb3df12262a0b31c11600acedf1544ac4fb.tar.xz
Add function to get message sender's UUID (#56)
* Add uuid function for chat messages * Does this please you, clippy?
-rw-r--r--azalea-client/Cargo.toml2
-rwxr-xr-xazalea-client/src/chat.rs10
2 files changed, 11 insertions, 1 deletions
diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml
index 05425e9c..40653308 100644
--- a/azalea-client/Cargo.toml
+++ b/azalea-client/Cargo.toml
@@ -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"
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.