Skip to content

Commit

Permalink
Moved can_not_join check to proper place. (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvsch authored Jan 31, 2025
1 parent e1e0576 commit 0e8f8ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions pumpkin/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ impl Client {
.await;
}
SAcknowledgeFinishConfig::PACKET_ID => {
self.handle_config_acknowledged();
self.handle_config_acknowledged().await;
}
SKnownPacks::PACKET_ID => {
self.handle_known_packs(server, SKnownPacks::read(bytebuf)?)
Expand Down Expand Up @@ -544,9 +544,7 @@ impl Client {

/// Checks if the client can join the server.
pub async fn can_not_join(&self) -> Option<TextComponent> {
let profile: tokio::sync::MutexGuard<'_, Option<GameProfile>> =
self.gameprofile.lock().await;

let profile = self.gameprofile.lock().await;
let Some(profile) = profile.as_ref() else {
return Some(TextComponent::text("Missing GameProfile"));
};
Expand Down
8 changes: 7 additions & 1 deletion pumpkin/src/net/packet/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,15 @@ impl Client {
self.send_packet(&CFinishConfig::new()).await;
}

pub fn handle_config_acknowledged(&self) {
pub async fn handle_config_acknowledged(&self) {
log::debug!("Handling config acknowledge");
self.connection_state.store(ConnectionState::Play);

if let Some(reason) = self.can_not_join().await {
self.kick(&reason).await;
return;
}

self.make_player
.store(true, std::sync::atomic::Ordering::Relaxed);
}
Expand Down
6 changes: 0 additions & 6 deletions pumpkin/src/net/packet/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,6 @@ impl Client {

*gameprofile = Some(profile);
}

drop(gameprofile);

if let Some(reason) = self.can_not_join().await {
self.kick(&reason).await;
}
}

pub async fn handle_encryption_response(
Expand Down

0 comments on commit 0e8f8ec

Please sign in to comment.