diff options
Diffstat (limited to 'azalea/src/swarm')
| -rw-r--r-- | azalea/src/swarm/chat.rs | 15 | ||||
| -rw-r--r-- | azalea/src/swarm/events.rs | 5 | ||||
| -rw-r--r-- | azalea/src/swarm/mod.rs | 14 |
3 files changed, 18 insertions, 16 deletions
diff --git a/azalea/src/swarm/chat.rs b/azalea/src/swarm/chat.rs index 303ce35b..6cf4d6b6 100644 --- a/azalea/src/swarm/chat.rs +++ b/azalea/src/swarm/chat.rs @@ -20,7 +20,8 @@ use crate::ecs::{ system::{Commands, Query, Res, ResMut, Resource}, }; use azalea_client::chat::{ChatPacket, ChatReceivedEvent}; -use bevy_app::{App, Plugin}; +use bevy_app::{App, Plugin, Update}; +use bevy_ecs::prelude::Event; use std::collections::VecDeque; use super::{Swarm, SwarmEvent}; @@ -30,7 +31,10 @@ pub struct SwarmChatPlugin; impl Plugin for SwarmChatPlugin { fn build(&self, app: &mut App) { app.add_event::<NewChatMessageEvent>() - .add_systems((chat_listener, update_min_index_and_shrink_queue).chain()) + .add_systems( + Update, + (chat_listener, update_min_index_and_shrink_queue).chain(), + ) .insert_resource(GlobalChatState { chat_queue: VecDeque::new(), chat_min_index: 0, @@ -44,7 +48,7 @@ pub struct ClientChatState { } /// A chat message that no other bots have seen yet was received by a bot. -#[derive(Debug)] +#[derive(Event, Debug)] pub struct NewChatMessageEvent(ChatPacket); #[derive(Resource)] @@ -160,7 +164,10 @@ mod tests { // event mangement in drain_events app.init_resource::<Events<ChatReceivedEvent>>() .init_resource::<Events<NewChatMessageEvent>>() - .add_systems((chat_listener, update_min_index_and_shrink_queue).chain()) + .add_systems( + Update, + (chat_listener, update_min_index_and_shrink_queue).chain(), + ) .insert_resource(GlobalChatState { chat_queue: VecDeque::new(), chat_min_index: 0, diff --git a/azalea/src/swarm/events.rs b/azalea/src/swarm/events.rs index 62593029..b4752abf 100644 --- a/azalea/src/swarm/events.rs +++ b/azalea/src/swarm/events.rs @@ -1,6 +1,6 @@ use azalea_client::LocalPlayer; use azalea_world::entity::MinecraftEntityId; -use bevy_app::{App, Plugin}; +use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; use derive_more::{Deref, DerefMut}; @@ -8,12 +8,13 @@ pub struct SwarmPlugin; impl Plugin for SwarmPlugin { fn build(&self, app: &mut App) { app.add_event::<SwarmReadyEvent>() - .add_system(check_ready) + .add_systems(Update, check_ready) .init_resource::<IsSwarmReady>(); } } /// All the bots from the swarm are now in the world. +#[derive(Event)] pub struct SwarmReadyEvent; #[derive(Default, Resource, Deref, DerefMut)] diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index ed70dacd..13741aa0 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -14,7 +14,7 @@ use azalea_protocol::{ ServerAddress, }; use azalea_world::InstanceContainer; -use bevy_app::{App, Plugin, PluginGroup, PluginGroupBuilder}; +use bevy_app::{App, PluginGroup, PluginGroupBuilder, Plugins}; use bevy_ecs::{component::Component, entity::Entity, system::Resource, world::World}; use futures::future::join_all; use log::error; @@ -234,16 +234,10 @@ where self } - /// Add a plugin to the swarm. + /// Add one or more plugins to this swarm. #[must_use] - pub fn add_plugin<T: Plugin>(mut self, plugin: T) -> Self { - self.app.add_plugin(plugin); - self - } - /// Add a group of plugins to the swarm. - #[must_use] - pub fn add_plugins<T: PluginGroup>(mut self, plugin_group: T) -> Self { - self.app.add_plugins(plugin_group); + pub fn add_plugins<M>(mut self, plugins: impl Plugins<M>) -> Self { + self.app.add_plugins(plugins); self } |
