From b83d12b1ab7d87e5317fccfb970a0d9aab341557 Mon Sep 17 00:00:00 2001 From: Shayne Hartford Date: Thu, 7 Nov 2024 17:00:59 -0500 Subject: [PATCH] 0.6.1 - Fix Whitelist Link --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/plugins/commands/whitelist.rs | 38 +++++++++++++++++++++++-------- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c36447c..ba81081 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3185,7 +3185,7 @@ dependencies = [ [[package]] name = "shaysbot" -version = "0.6.0" +version = "0.6.1" dependencies = [ "anyhow", "azalea", diff --git a/Cargo.toml b/Cargo.toml index 5e13193..3034fd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shaysbot" -version = "0.6.0" +version = "0.6.1" authors = ["Shayne Hartford "] edition = "2021" description = "My personal Minecraft bot using Azalea" diff --git a/src/plugins/commands/whitelist.rs b/src/plugins/commands/whitelist.rs index 70254e3..d2ea385 100644 --- a/src/plugins/commands/whitelist.rs +++ b/src/plugins/commands/whitelist.rs @@ -66,17 +66,17 @@ pub fn handle_whitelist_command_event( continue; }; - let Some((uuid, _info)) = tab_list - .iter() - .find(|(_, info)| info.profile.name == username) - else { - whisper_event.content = String::from("[404] Player not found"); - whisper_events.send(whisper_event); - continue; - }; - whisper_event.content = match action.as_ref() { "add" => { + let Some((uuid, _info)) = tab_list + .iter() + .find(|(_, info)| info.profile.name == username) + else { + whisper_event.content = String::from("[404] Player not found"); + whisper_events.send(whisper_event); + continue; + }; + if settings.whitelist.contains_key(uuid) { String::from("[409] Already whitelisted.") } else { @@ -87,6 +87,15 @@ pub fn handle_whitelist_command_event( } } "remove" => { + let Some((uuid, _info)) = tab_list + .iter() + .find(|(_, info)| info.profile.name == username) + else { + whisper_event.content = String::from("[404] Player not found"); + whisper_events.send(whisper_event); + continue; + }; + if settings.whitelist.contains_key(uuid) { settings.whitelist.remove(uuid); settings.save().expect("Failed to save settings"); @@ -100,7 +109,16 @@ pub fn handle_whitelist_command_event( CommandSender::Discord(_) => { String::from("[403] You must run this sub-command in-game") } - CommandSender::Minecraft(_) => { + CommandSender::Minecraft(sender) => { + let Some((uuid, _info)) = tab_list + .iter() + .find(|(_, info)| &info.profile.name == sender) + else { + whisper_event.content = String::from("[404] Sender not found"); + whisper_events.send(whisper_event); + continue; + }; + settings.whitelist.insert(*uuid, Some(username)); settings.save().expect("Failed to save settings");