diff options
Diffstat (limited to 'bot/src')
| -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(()) } |
