From 6447bc0bb647ecb3349ecbec5f8691a6ff5291c0 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Thu, 26 Jan 2023 17:22:39 +0800 Subject: [PATCH] Add Location command --- src/bot.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/bot.rs b/src/bot.rs index bfdc910..d1dd107 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -16,6 +16,7 @@ pub enum Command { Help, Wait, Online, + Location, BotStatus, Whitelist, WhitelistAdd, @@ -69,6 +70,7 @@ pub async fn process_command( "help" => command = Command::Help, "wait" => command = Command::Wait, "online" => command = Command::Online, + "location" => command = Command::Location, "bot_status" => command = Command::BotStatus, "whitelist" => command = Command::Whitelist, "whitelist_add" => command = Command::WhitelistAdd, @@ -173,6 +175,17 @@ pub async fn process_command( paged_players.join(", ") ); } + Command::Location => { + let world = client.world.read(); + let entity = match world.entity(client.entity_id.read().to_owned()) { + Some(entity) => entity, + None => return "Uh oh! An unknown error occurred!".to_string(), + }; + return format!( + "I am currently at {} {} {}!", + entity.last_pos.x as i32, entity.last_pos.y as i32, entity.last_pos.z as i32 + ); + } Command::BotStatus => { let bot_status = state.bot_status.lock().unwrap().to_owned(); let metadata = client.metadata();