aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/plugins/disconnect.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-05-09 14:12:51 -1030
committermat <git@matdoes.dev>2025-05-09 14:12:51 -1030
commite9b3128103d203ad4902a40124e4d22a012c196a (patch)
tree3f8211f88a72ff63c4349efc694d90def3a6d8da /azalea-client/src/plugins/disconnect.rs
parent1493c06de597fc320b79212d133f08c678763a6b (diff)
downloadazalea-drasl-e9b3128103d203ad4902a40124e4d22a012c196a.tar.xz
don't send chat signing certs on offline-mode servers
Diffstat (limited to 'azalea-client/src/plugins/disconnect.rs')
-rw-r--r--azalea-client/src/plugins/disconnect.rs34
1 files changed, 23 insertions, 11 deletions
diff --git a/azalea-client/src/plugins/disconnect.rs b/azalea-client/src/plugins/disconnect.rs
index 3e27eba3..c1c962d5 100644
--- a/azalea-client/src/plugins/disconnect.rs
+++ b/azalea-client/src/plugins/disconnect.rs
@@ -7,6 +7,7 @@ use bevy_ecs::prelude::*;
use derive_more::Deref;
use tracing::info;
+use super::login::IsAuthenticated;
use crate::{InstanceHolder, chat_signing, client::JoinedClientBundle, connection::RawConnection};
pub struct DisconnectPlugin;
@@ -44,6 +45,27 @@ pub struct DisconnectEvent {
pub reason: Option<FormattedText>,
}
+/// A bundle of components that are removed when a client disconnects.
+///
+/// This shouldn't be used for inserts because not all of the components should
+/// always be present.
+#[derive(Bundle)]
+pub struct RemoveOnDisconnectBundle {
+ pub joined_client: JoinedClientBundle,
+ pub entity: EntityBundle,
+ pub instance_holder: InstanceHolder,
+ pub player_metadata: PlayerMetadataBundle,
+ pub in_loaded_chunk: InLoadedChunk,
+ //// This makes it close the TCP connection.
+ pub raw_connection: RawConnection,
+ /// This makes it not send [`DisconnectEvent`] again.
+ pub is_connection_alive: IsConnectionAlive,
+ /// Resend our chat signing certs next time.
+ pub chat_signing_session: chat_signing::ChatSigningSession,
+ /// They're not authenticated anymore if they disconnected.
+ pub is_authenticated: IsAuthenticated,
+}
+
/// A system that removes the several components from our clients when they get
/// a [`DisconnectEvent`].
pub fn remove_components_from_disconnected_players(
@@ -62,17 +84,7 @@ pub fn remove_components_from_disconnected_players(
);
commands
.entity(*entity)
- .remove::<JoinedClientBundle>()
- .remove::<EntityBundle>()
- .remove::<InstanceHolder>()
- .remove::<PlayerMetadataBundle>()
- .remove::<InLoadedChunk>()
- // this makes it close the tcp connection
- .remove::<RawConnection>()
- // this makes it not send DisconnectEvent again
- .remove::<IsConnectionAlive>()
- // resend our chat signing certs next time
- .remove::<chat_signing::ChatSigningSession>();
+ .remove::<RemoveOnDisconnectBundle>();
// note that we don't remove the client from the ECS, so if they decide
// to reconnect they'll keep their state