diff options
| author | mat <github@matdoes.dev> | 2022-09-19 23:05:05 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-09-19 23:05:05 -0500 |
| commit | e63f605c824d62231bc2741347f8743a62e00617 (patch) | |
| tree | f43846da56ef9813d2a6a7384bc00f4053c70260 /bot/src/main.rs | |
| parent | a87c4cf718fcf7b16fecf463333bd46310c88c87 (diff) | |
| download | azalea-drasl-e63f605c824d62231bc2741347f8743a62e00617.tar.xz | |
add shutdown function
Diffstat (limited to 'bot/src/main.rs')
| -rw-r--r-- | bot/src/main.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/bot/src/main.rs b/bot/src/main.rs index 5423e017..92c1bc91 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -1,8 +1,11 @@ use azalea_client::{Account, Client, Event, MoveDirection}; +use azalea_protocol::packets::game::ClientboundGamePacket; use std::convert::TryInto; #[tokio::main] async fn main() { + env_logger::init(); + let bot = Account::offline("bot"); let (bot, mut rx) = bot.join(&"localhost".try_into().unwrap()).await.unwrap(); @@ -12,7 +15,7 @@ async fn main() { } } -async fn handle_event(event: Event, mut bot: Client) { +async fn handle_event(event: Event, mut bot: Client) -> anyhow::Result<()> { match event { Event::Login => { // tokio::time::sleep(std::time::Duration::from_secs(1)).await; @@ -22,6 +25,15 @@ async fn handle_event(event: Event, mut bot: Client) { // } // bot.walk(MoveDirection::None); } + Event::Packet(packet) => { + if let ClientboundGamePacket::SetHealth(_) = *packet { + println!("got set health"); + bot.shutdown().await?; + panic!(); + } + } _ => {} } + + Ok(()) } |
