From 4524f6e31cc7165b16a1480979fced43c9066016 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sun, 27 Jun 2021 11:20:28 +0200 Subject: [PATCH] Remove empty nicks from the 'list' command. --- backend/src/minecraft_controller.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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"); -- 2.45.2