From: Greg Burri Date: Sun, 27 Jun 2021 09:20:28 +0000 (+0200) Subject: Remove empty nicks from the 'list' command. X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=4524f6e31cc7165b16a1480979fced43c9066016;p=minecraft_web.git Remove empty nicks from the 'list' command. --- diff --git a/backend/src/minecraft_controller.rs b/backend/src/minecraft_controller.rs index a644c4d..9287cda 100644 --- a/backend/src/minecraft_controller.rs +++ b/backend/src/minecraft_controller.rs @@ -88,8 +88,13 @@ fn get_status_from_rcon(rcon_password: &str) -> StatusFromRcon { match client.send_command("list".to_string()) { Ok(resp) => match resp.body.find(':') { - Some(i) => resp.body[i + 1..resp.body.len() - 1].split(',').map(|nick| nick.trim().to_string()).collect(), - None => Vec::new() + Some(i) if i < resp.body.len() -1 => + resp.body[i + 1..resp.body.len() - 1] + .split(',') + .map(|nick| nick.trim().to_string()) + .filter(|nick| !nick.is_empty()) + .collect(), + _ => Vec::new() }, Err(_e) => { println!("Error from 'list' command");