1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

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>
This commit is contained in:
EightFactorial 2023-01-06 16:30:55 -08:00 committed by GitHub
parent 0bca3d8f5d
commit 0c30138d26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);