diff options
| author | mat <git@matdoes.dev> | 2026-01-28 05:41:51 +0600 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-28 05:41:51 +0600 |
| commit | 679b112deeee1be9f773c6bd369bc1a975fe1628 (patch) | |
| tree | 6369737e480a97419955058a23a6b8497e13a335 /azalea/src/swarm | |
| parent | 0ba73a30dc6cdba3cafd726b4a94afee6157d035 (diff) | |
| download | azalea-drasl-679b112deeee1be9f773c6bd369bc1a975fe1628.tar.xz | |
add Client::exit and Swarm::exit, and write related docs
Diffstat (limited to 'azalea/src/swarm')
| -rw-r--r-- | azalea/src/swarm/mod.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index 4ecb0726..de4d2ebe 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -16,7 +16,7 @@ use azalea_client::{account::Account, chat::ChatPacket, join::ConnectOpts}; use azalea_entity::LocalEntity; use azalea_protocol::address::ResolvedAddr; use azalea_world::Worlds; -use bevy_app::{PluginGroup, PluginGroupBuilder}; +use bevy_app::{AppExit, PluginGroup, PluginGroupBuilder}; use bevy_ecs::prelude::*; pub use builder::SwarmBuilder; use futures::future::BoxFuture; @@ -291,6 +291,21 @@ impl Swarm { let mut query = ecs.query_filtered::<Entity, With<LocalEntity>>(); query.iter(&ecs).collect::<Box<[Entity]>>() } + + /// End the entire swarm and return from [`SwarmBuilder::start`]. + /// + /// You should typically avoid calling this if you intend on creating the + /// swarm again, because creating an entirely new swarm can be a + /// relatively expensive process. + /// + /// If you only want to change the server that the bots are connecting to, + /// it may be better to call [`Swarm::add_with_opts`] with a different + /// server address. + /// + /// This is also implemented on [`Client`] as [`Client::exit`]. + pub fn exit(&self) { + self.ecs.write().write_message(AppExit::Success); + } } impl IntoIterator for Swarm { |
