Fix how the output of the list command is handled
[minecraft_web.git] / backend / src / minecraft_controller.rs
index 163008a..a644c4d 100644 (file)
@@ -86,14 +86,11 @@ fn get_status_from_rcon(rcon_password: &str) -> StatusFromRcon {
                 StatusFromRcon {\r
                     players:\r
                         match client.send_command("list".to_string()) {\r
-                            Ok(resp) => {\r
-                                resp.body\r
-                                    .split('\n')\r
-                                    .skip(1)\r
-                                    .filter(|n| !n.is_empty())\r
-                                    .map(|n| n.to_string())\r
-                                    .collect()\r
-                            },\r
+                            Ok(resp) =>\r
+                                match resp.body.find(':') {\r
+                                    Some(i) => resp.body[i + 1..resp.body.len() - 1].split(',').map(|nick| nick.trim().to_string()).collect(),\r
+                                    None => Vec::new()\r
+                                },\r
                             Err(_e) => {\r
                                 println!("Error from 'list' command");\r
                                 Vec::new()\r