diff options
| author | EightFactorial <murphkev000@gmail.com> | 2023-01-06 16:30:55 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-06 18:30:55 -0600 |
| commit | 0c30138d26e8192468507b12683daf32e8fdbc29 (patch) | |
| tree | f6f56bf0514d5ac48088468e07b9f872e012e072 | |
| parent | 0bca3d8f5d1d2480a2bfeb97280480dd91d0556a (diff) | |
| download | azalea-drasl-0c30138d26e8192468507b12683daf32e8fdbc29.tar.xz | |
Add reason for disconnect (#54)
* Add reason for disconnect
Handles messages like "The server is full!" and "Banned by an operator."
Ban reasons are shown like "You are banned from this server.\nReason: foo"
* keep the kick reason as a Component in the error
Co-authored-by: mat <github@matdoes.dev>
| -rw-r--r-- | azalea-client/src/client.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 4282df46..dbb1b71e 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -1,6 +1,7 @@ pub use crate::chat::ChatPacket; use crate::{movement::WalkDirection, plugins::PluginStates, Account, PlayerInfo}; use azalea_auth::{game_profile::GameProfile, sessionserver::SessionServerError}; +use azalea_chat::Component; use azalea_core::{ChunkPos, ResourceLocation, Vec3}; use azalea_protocol::{ connect::{Connection, ConnectionError, ReadConnection, WriteConnection}, @@ -145,6 +146,8 @@ pub enum JoinError { InvalidAddress, #[error("Couldn't refresh access token: {0}")] Auth(#[from] azalea_auth::AuthError), + #[error("Disconnected: {reason}")] + Disconnect { reason: Component }, } #[derive(Error, Debug)] @@ -346,6 +349,7 @@ impl Client { } ClientboundLoginPacket::LoginDisconnect(p) => { debug!("Got disconnect {:?}", p); + return Err(JoinError::Disconnect { reason: p.reason }); } ClientboundLoginPacket::CustomQuery(p) => { debug!("Got custom query {:?}", p); |
