use azalea::{ prelude::*, GameProfileComponent, entity::{metadata::Player, Position}, pathfinder::goals::BlockPosGoal, ecs::query::With, }; pub async fn execute( bot: Client, sender: String, mut command: String, args: Vec, ) -> anyhow::Result { if command.starts_with('!') { command.remove(0); } command = command.to_lowercase(); match command.as_str() { "help" => { send_command(bot, &format!("msg {sender} Доступные комманды: !help - Помощь, !tp - телепорт к Вам, !walk - подойдет к Вам (разрушая блоки), !say - скажет, что Вы прикажете, !stop - завершит работу")); Ok(true) } "stop" => { info!("Stopping... Bye!"); std::process::exit(0); } "walk" => { let sender_entity = bot.entity_by::, (&GameProfileComponent,)>( |(profile,): &(&GameProfileComponent,)| profile.name == sender, ); if let Some(sender_entity) = sender_entity { let position = bot.entity_component::(sender_entity); let goal = BlockPosGoal(azalea::BlockPos { x: position.x.floor() as i32, y: position.y.floor() as i32, z: position.z.floor() as i32, }); send_command( bot.clone(), &format!("msg {sender} Бегу к тебе!"), ); // bot.goto_without_mining(goal).await; bot.goto(goal).await; } else { send_command( bot, &format!("msg {sender} Не могу найти тебя! Возможно ты не в радиусе моей прогрузки :("), ); } Ok(true) } "tp" => { info!("Teleporting to: {sender}"); send_command(bot, &format!("tpa {sender}")); Ok(true) } "say" => { let command_or_chat = args.join(" "); if command_or_chat.starts_with("/") { info!("Sending command: {command_or_chat}"); bot.send_command_packet(&format!("{}", &command_or_chat[1..])); } else { info!("Sending chat message: {command_or_chat}"); bot.send_chat_packet(&command_or_chat); } Ok(true) } _ => Ok(false), } } pub fn send_command(bot: Client, command: &str) { info!("Sending command: {command}"); bot.send_command_packet(command); }