diff options
| -rw-r--r-- | azalea-client/src/client.rs | 7 | ||||
| -rw-r--r-- | bot/src/main.rs | 23 |
2 files changed, 19 insertions, 11 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index ff2e02a9..7f6e591a 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -31,7 +31,7 @@ use azalea_world::{ entity::{metadata, EntityData, EntityMetadata, EntityMut, EntityRef}, Dimension, }; -use log::{debug, error, warn}; +use log::{debug, error, info, warn}; use parking_lot::{Mutex, RwLock}; use std::{ fmt::Debug, @@ -309,6 +309,11 @@ impl Client { } }, Err(e) => { + if let ReadPacketError::ConnectionClosed = e { + info!("Connection closed"); + client.shutdown().await; + return; + } if IGNORE_ERRORS { warn!("{}", e); match e { diff --git a/bot/src/main.rs b/bot/src/main.rs index e4543b6a..6e66d2ee 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -8,17 +8,20 @@ struct State {} async fn main() -> anyhow::Result<()> { env_logger::init(); - let account = Account::microsoft("example@example.com").await?; + // let account = Account::microsoft("example@example.com").await?; + let account = Account::offline("bot"); - azalea::start(azalea::Options { - account, - address: "localhost", - state: State::default(), - plugins: vec![], - handle, - }) - .await - .unwrap(); + loop { + let e = azalea::start(azalea::Options { + account: account.clone(), + address: "localhost", + state: State::default(), + plugins: vec![], + handle, + }) + .await; + println!("{:?}", e); + } Ok(()) } |
