aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/disconnect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-client/src/disconnect.rs')
-rw-r--r--azalea-client/src/disconnect.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/azalea-client/src/disconnect.rs b/azalea-client/src/disconnect.rs
index 9fd57e57..3b8d133e 100644
--- a/azalea-client/src/disconnect.rs
+++ b/azalea-client/src/disconnect.rs
@@ -1,30 +1,30 @@
//! Disconnect a client from the server.
-use azalea_ecs::{
- app::{App, CoreStage, Plugin},
+use bevy_app::{App, CoreSet, Plugin};
+use bevy_ecs::{
component::Component,
entity::Entity,
event::{EventReader, EventWriter},
query::Changed,
- schedule::IntoSystemDescriptor,
+ schedule::IntoSystemConfigs,
system::{Commands, Query},
- AppTickExt,
};
use derive_more::Deref;
-use crate::{client::JoinedClientBundle, movement::send_position, LocalPlayer};
+use crate::{client::JoinedClientBundle, LocalPlayer};
pub struct DisconnectPlugin;
impl Plugin for DisconnectPlugin {
fn build(&self, app: &mut App) {
- app.add_event::<DisconnectEvent>()
- .add_system_to_stage(CoreStage::PostUpdate, handle_disconnect)
- .add_tick_system(
- update_read_packets_task_running_component
- .before(disconnect_on_read_packets_ended)
- .before(send_position),
+ app.add_event::<DisconnectEvent>().add_systems(
+ (
+ update_read_packets_task_running_component,
+ disconnect_on_read_packets_ended,
+ remove_components_from_disconnected_players,
)
- .add_tick_system(disconnect_on_read_packets_ended);
+ .in_base_set(CoreSet::PostUpdate)
+ .chain(),
+ );
}
}
@@ -35,7 +35,10 @@ pub struct DisconnectEvent {
/// System that removes the [`JoinedClientBundle`] from the entity when it
/// receives a [`DisconnectEvent`].
-pub fn handle_disconnect(mut commands: Commands, mut events: EventReader<DisconnectEvent>) {
+pub fn remove_components_from_disconnected_players(
+ mut commands: Commands,
+ mut events: EventReader<DisconnectEvent>,
+) {
for DisconnectEvent { entity } in events.iter() {
commands.entity(*entity).remove::<JoinedClientBundle>();
}