aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-09-28 16:51:06 +1100
committermat <git@matdoes.dev>2025-09-28 16:51:06 +1100
commit5ed0c5d635b1c28721b3c32f1d6ce04a30934992 (patch)
tree187115969a656fd74851da925edfc3fb14d26edd /azalea
parent74dcb7b37d953ec4d45dd6aac4c8e598c87def7d (diff)
downloadazalea-drasl-5ed0c5d635b1c28721b3c32f1d6ce04a30934992.tar.xz
update deps
Diffstat (limited to 'azalea')
-rw-r--r--azalea/README.md6
-rw-r--r--azalea/examples/testbot/commands/debug.rs22
-rw-r--r--azalea/src/lib.rs1
3 files changed, 25 insertions, 4 deletions
diff --git a/azalea/README.md b/azalea/README.md
index ec25bfd0..5d0b6d5f 100644
--- a/azalea/README.md
+++ b/azalea/README.md
@@ -56,8 +56,10 @@ async fn main() {
#[derive(Default, Clone, Component)]
pub struct State {
- // The state gets cloned whenever the handler is called, so to have all the
- // clones point to the same data and have it be mutable, we use an Arc<Mutex<T>>.
+ /// An example field that stores the number of messages that've been
+ /// received by the client so far. The state gets cloned whenever the
+ /// handler is called, so to have all the clones point to the same data and
+ /// have it be mutable, we use an Arc<Mutex<T>>.
pub messages_received: Arc<Mutex<usize>>
}
diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs
index 23e29b00..3cdf4cf2 100644
--- a/azalea/examples/testbot/commands/debug.rs
+++ b/azalea/examples/testbot/commands/debug.rs
@@ -14,11 +14,11 @@ use azalea::{
world::MinecraftEntityId,
};
use azalea_core::hit_result::HitResult;
-use azalea_entity::EntityKindComponent;
+use azalea_entity::{EntityKindComponent, EntityUuid, metadata};
use azalea_inventory::components::MaxStackSize;
use azalea_world::InstanceContainer;
use bevy_app::AppExit;
-use bevy_ecs::event::Events;
+use bevy_ecs::{event::Events, query::With};
use parking_lot::Mutex;
use super::{CommandSource, Ctx};
@@ -214,6 +214,24 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
1
}));
+ commands.register(literal("players").executes(|ctx: &Ctx| {
+ let source = ctx.source.lock();
+ let player_entities = source
+ .bot
+ .nearest_entities_by::<With<metadata::Player>, ()>(|_: &()| true);
+ let tab_list = source.bot.tab_list();
+ for player_entity in player_entities {
+ let uuid = source.bot.entity_component::<EntityUuid>(player_entity);
+ source.reply(format!(
+ "{} - {} ({:?})",
+ player_entity,
+ tab_list.get(&uuid).map_or("?", |p| p.profile.name.as_str()),
+ uuid
+ ));
+ }
+ 1
+ }));
+
commands.register(literal("debugecsleak").executes(|ctx: &Ctx| {
let source = ctx.source.lock();
diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs
index ae49c649..e3e92170 100644
--- a/azalea/src/lib.rs
+++ b/azalea/src/lib.rs
@@ -46,6 +46,7 @@ pub type BoxHandleFn<S, R> =
Box<dyn Fn(Client, azalea_client::Event, S) -> BoxFuture<'static, R> + Send>;
pub type HandleFn<S, Fut> = fn(Client, azalea_client::Event, S) -> Fut;
+/// An error related to resolving the server address when starting a client.
#[derive(Error, Debug)]
pub enum StartError {
#[error("Invalid address")]