Fix possible bugs

This commit is contained in:
ErrorNoInternet 2023-01-22 15:37:00 +08:00
parent 4fc4a401d6
commit 122da153bc
Signed by untrusted user who does not match committer: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3

@ -220,7 +220,8 @@ pub async fn process_command(
return "Please tell me the name of a player!".to_string();
}
for (player, position_time_data) in state.player_locations.lock().unwrap().iter() {
let player_locations = state.player_locations.lock().unwrap().to_owned();
for (player, position_time_data) in player_locations {
if player.username == segments[0] || player.uuid.to_string() == segments[0] {
return format!(
"{} was last seen at {}, {}, {} ({})",
@ -328,7 +329,8 @@ pub async fn process_command(
};
let mut found = true;
for (player, _position_time_data) in state.player_locations.lock().unwrap().iter() {
let player_locations = state.player_locations.lock().unwrap().to_owned();
for (player, _position_time_data) in player_locations {
if player.username == segments[0] || player.uuid.to_string() == segments[0] {
found = true;
*state.followed_player.lock().unwrap() = Some(player.to_owned());