From 81538cec816076536af20128e15ba0068b4ab726 Mon Sep 17 00:00:00 2001 From: Shayne Hartford Date: Fri, 29 Nov 2024 03:26:54 -0500 Subject: [PATCH] 0.8.3 - Pearl Location --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands/pearl.rs | 21 ++++++++++++--------- src/settings.rs | 6 +++--- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 627cb1f..60db64e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3212,7 +3212,7 @@ dependencies = [ [[package]] name = "shaysbot" -version = "0.8.2" +version = "0.8.3" dependencies = [ "anyhow", "azalea", diff --git a/Cargo.toml b/Cargo.toml index 18b3a79..7c65324 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shaysbot" -version = "0.8.2" +version = "0.8.3" authors = ["Shayne Hartford "] edition = "2021" description = "My personal Minecraft bot using Azalea" diff --git a/src/commands/pearl.rs b/src/commands/pearl.rs index 67030a4..8323ad8 100644 --- a/src/commands/pearl.rs +++ b/src/commands/pearl.rs @@ -65,7 +65,7 @@ pub fn handle_pearl_command_event( }; whisper_event.content = format!( - "[404] Invalid or Missing location, Available location(s): {}", + "[404] Invalid location, Available locations: {}", settings .locations .keys() @@ -121,19 +121,22 @@ pub fn handle_pearl_command_event( let (alias, bot) = match event.args.pop_front() { Some(alias) => match settings.locations.get_key_value(&alias) { - Some((alias, bot_settings)) if bot_settings.account_username == profile.name => { - (alias, bot_settings) - } + Some(l) if l.1.account_username == profile.name => l, Some(_) => { whisper_event.content = str!("[500] I'm not at that location"); whisper_events.send(whisper_event); continue; } - _ => { - whisper_events.send(whisper_event); - command_events.clear(); - return; - } + _ => match event.source { + CommandSource::Minecraft(_) if settings.locations.len() == 1 => { + settings.locations.iter().next().unwrap() + } + _ => { + whisper_events.send(whisper_event); + command_events.clear(); + return; + } + }, }, None => match event.source { CommandSource::Discord(_) => match settings.locations.iter().next() { diff --git a/src/settings.rs b/src/settings.rs index 0705799..a17832c 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -59,7 +59,7 @@ pub struct Settings { /// Minecraft bot accounts #[default(HashMap::from([ - (str!("primary"), BotSettings::new(str!("Test"))), + (str!("primary"), BotSettings::new(str!("ShaysBot"))), #[cfg(debug_assertions)] (str!("secondary"), BotSettings::new(str!("Fishdar"))), ]))] @@ -91,7 +91,7 @@ pub enum EncryptionMode { } #[serde_as] -#[derive(Clone, Component, Deserialize, Serialize, SmartDefault, New)] +#[derive(Clone, Component, Debug, Deserialize, Serialize, SmartDefault, New)] #[serde(default)] pub struct BotSettings { /// Minecraft Online Mode. @@ -124,7 +124,7 @@ pub struct BotSettings { } #[serde_as] -#[derive(Clone, Default, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] pub struct IdleGoal { #[serde_as(as = "DisplayFromStr")] pub coords: Vec3,