diff options
| author | mat <git@matdoes.dev> | 2023-05-13 19:29:55 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-05-13 19:29:55 -0500 |
| commit | 0cc76dfb67e852868e30d1c8529826c41a18e9d1 (patch) | |
| tree | 2e8c8c9aa3702431608509caa75dd3b5c8329f14 | |
| parent | ca39b8b6af27a91431d2a837037881bc882f0dde (diff) | |
| download | azalea-drasl-0cc76dfb67e852868e30d1c8529826c41a18e9d1.tar.xz | |
ChatPacket::is_whisper
| -rwxr-xr-x | azalea-client/src/chat.rs | 10 | ||||
| -rw-r--r-- | azalea/src/lib.rs | 2 | ||||
| -rw-r--r-- | azalea/src/pathfinder/mod.rs | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/azalea-client/src/chat.rs b/azalea-client/src/chat.rs index 0ae0250a..90618c80 100755 --- a/azalea-client/src/chat.rs +++ b/azalea-client/src/chat.rs @@ -108,6 +108,16 @@ impl ChatPacket { overlay: false, })) } + + /// Whether this message was sent with /msg (or aliases). It works by + /// checking the translation key, so it won't work on servers that use their + /// own whisper system. + pub fn is_whisper(&self) -> bool { + match self.message() { + FormattedText::Text(_) => false, + FormattedText::Translatable(t) => t.key == "commands.message.display.incoming", + } + } } impl Client { diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs index 8a00ff71..dcfa43b1 100644 --- a/azalea/src/lib.rs +++ b/azalea/src/lib.rs @@ -14,7 +14,7 @@ use app::{App, Plugin, PluginGroup}; pub use azalea_auth as auth; pub use azalea_block as blocks; pub use azalea_brigadier as brigadier; -pub use azalea_chat as chat; +pub use azalea_chat::FormattedText; pub use azalea_client::*; pub use azalea_core::{BlockPos, Vec3}; pub use azalea_protocol as protocol; diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index 4db18b0e..b7ed222d 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -70,7 +70,7 @@ pub trait PathfinderClientExt { } impl PathfinderClientExt for azalea_client::Client { - /// ```no_run + /// ``` /// # use azalea::prelude::*; /// # use azalea::{BlockPos, pathfinder::BlockPosGoal}; /// # fn example(bot: &Client) { |
