X-Git-Url: http://git.euphorik.ch/index.cgi?p=minecraft_web.git;a=blobdiff_plain;f=backend%2Fsrc%2Fminecraft_controller.rs;fp=backend%2Fsrc%2Fminecraft_controller.rs;h=d9a68c0107c3cb1488abf429cd94de55b0b0d100;hp=9bcc7d33f3cca961b54465acfcbc6f4cbe83be86;hb=5df9e614e940f47256773b7d0787e46f90082ff7;hpb=1b24eca7c07076d8706aca658778256230fd73b9 diff --git a/backend/src/minecraft_controller.rs b/backend/src/minecraft_controller.rs index 9bcc7d3..d9a68c0 100644 --- a/backend/src/minecraft_controller.rs +++ b/backend/src/minecraft_controller.rs @@ -75,12 +75,6 @@ fn format_byte_size(bytes: u64, precision: usize) -> String { const MINECRAFT_PROCESS_NAME: &str = "java"; -#[cfg(target_os = "linux")] -const STRING_BEFORE_CHARACTER_NAME: &str = "Got character ZDOID from"; - -#[cfg(target_os = "linux")] -const STRING_BEFORE_NB_OF_CONNECTIONS: &str = "Connections"; - // It doesn't work for the moment, it only scan the connection event and do not treat disconnections. fn get_active_players(rcon_password: &str) -> Vec { let mut client = minecraft_client_rs::Client::new("127.0.0.1:25575".to_string()).unwrap(); @@ -90,11 +84,15 @@ fn get_active_players(rcon_password: &str) -> Vec { Ok(_) => { match client.send_command("list".to_string()) { Ok(resp) => { - println!("{}", resp.body); - Vec::new() + resp.body + .split('\n') + .skip(1) + .filter(|n| !n.is_empty()) + .map(|n| n.to_string()) + .collect() }, Err(_e) => { - println!("Error asking seed"); + println!("Error from 'list' command"); Vec::new() }, }