From d1afd02aa84e7b4450c1607277f078eb2a0f1bf3 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sun, 9 Jul 2023 19:11:29 -0500 Subject: Update to Bevy 0.11 (#94) * update to bevy 0.11 * clippy --------- Co-authored-by: mat --- azalea/src/swarm/chat.rs | 15 +++++++++++---- azalea/src/swarm/events.rs | 5 +++-- azalea/src/swarm/mod.rs | 14 ++++---------- 3 files changed, 18 insertions(+), 16 deletions(-) (limited to 'azalea/src/swarm') 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::() - .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::>() .init_resource::>() - .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::() - .add_system(check_ready) + .add_systems(Update, check_ready) .init_resource::(); } } /// 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(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(mut self, plugin_group: T) -> Self { - self.app.add_plugins(plugin_group); + pub fn add_plugins(mut self, plugins: impl Plugins) -> Self { + self.app.add_plugins(plugins); self } -- cgit v1.2.3