X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=backend%2Fsrc%2Fminecraft_controller.rs;h=f04ed24d974085fc1dbde4d832cbe0150373b602;hb=026120042fe286bc09af4b5f38a345954d73f681;hp=9bcc7d33f3cca961b54465acfcbc6f4cbe83be86;hpb=1b24eca7c07076d8706aca658778256230fd73b9;p=minecraft_web.git diff --git a/backend/src/minecraft_controller.rs b/backend/src/minecraft_controller.rs index 9bcc7d3..f04ed24 100644 --- a/backend/src/minecraft_controller.rs +++ b/backend/src/minecraft_controller.rs @@ -35,13 +35,11 @@ impl MinecraftExe { } pub fn format_active_players(&self) -> String { - /* Commented because the player list isn't correct (the number is). if self.active_players.len() == 0 { String::from("") } else { self.active_players.join(", ") - }*/ - self.active_players.len().to_string() + } } pub fn format_last_backup(&self) -> String { @@ -75,12 +73,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 +82,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() }, }