mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
more verbose login_disconnect error
This commit is contained in:
parent
78e5a65317
commit
527333f2b7
1 changed files with 11 additions and 1 deletions
|
@ -4,6 +4,7 @@ use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
|
|||
use azalea_chat::FormattedText;
|
||||
use azalea_protocol_macros::ClientboundLoginPacket;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::trace;
|
||||
|
||||
#[derive(Clone, Debug, ClientboundLoginPacket)]
|
||||
pub struct ClientboundLoginDisconnect {
|
||||
|
@ -13,7 +14,16 @@ pub struct ClientboundLoginDisconnect {
|
|||
impl AzaleaRead for ClientboundLoginDisconnect {
|
||||
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<ClientboundLoginDisconnect, BufReadError> {
|
||||
let disconnect_string = String::azalea_read(buf)?;
|
||||
let disconnect_json: serde_json::Value = serde_json::from_str(disconnect_string.as_str())?;
|
||||
trace!("Got disconnect packet with string: {disconnect_string:?}");
|
||||
let disconnect_json =
|
||||
match serde_json::from_str::<serde_json::Value>(disconnect_string.as_str()) {
|
||||
Ok(json) => json,
|
||||
Err(err) => {
|
||||
return Err(BufReadError::Custom(format!(
|
||||
"Failed to deserialize disconnect JSON {disconnect_string:?}: {err}"
|
||||
)))
|
||||
}
|
||||
};
|
||||
|
||||
Ok(ClientboundLoginDisconnect {
|
||||
reason: FormattedText::deserialize(disconnect_json)?,
|
||||
|
|
Loading…
Add table
Reference in a new issue