From ca39b8b6af27a91431d2a837037881bc882f0dde Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 13 May 2023 19:08:08 -0500 Subject: reexport azalea-chat and add goto docs --- azalea/src/pathfinder/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'azalea/src/pathfinder/mod.rs') diff --git a/azalea/src/pathfinder/mod.rs b/azalea/src/pathfinder/mod.rs index 3f978c95..4db18b0e 100644 --- a/azalea/src/pathfinder/mod.rs +++ b/azalea/src/pathfinder/mod.rs @@ -70,6 +70,13 @@ pub trait PathfinderClientExt { } impl PathfinderClientExt for azalea_client::Client { + /// ```no_run + /// # use azalea::prelude::*; + /// # use azalea::{BlockPos, pathfinder::BlockPosGoal}; + /// # fn example(bot: &Client) { + /// bot.goto(BlockPosGoal::from(BlockPos::new(0, 70, 0))); + /// # } + /// ``` fn goto(&self, goal: impl Goal + Send + Sync + 'static) { self.ecs.lock().send_event(GotoEvent { entity: self.entity, -- cgit v1.2.3 From 0cc76dfb67e852868e30d1c8529826c41a18e9d1 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 13 May 2023 19:29:55 -0500 Subject: ChatPacket::is_whisper --- azalea-client/src/chat.rs | 10 ++++++++++ azalea/src/lib.rs | 2 +- azalea/src/pathfinder/mod.rs | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'azalea/src/pathfinder/mod.rs') 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) { -- cgit v1.2.3