From: Greg Burri Date: Thu, 5 May 2022 22:30:05 +0000 (+0200) Subject: Get the version from the process command line (WIP) X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=26d8ecd93415beb2d4d11376972cdfe412a73301;p=minecraft_web.git Get the version from the process command line (WIP) --- diff --git a/backend/src/minecraft_controller.rs b/backend/src/minecraft_controller.rs index 115cb55..be58549 100644 --- a/backend/src/minecraft_controller.rs +++ b/backend/src/minecraft_controller.rs @@ -77,8 +77,7 @@ fn format_byte_size(bytes: u64, precision: usize) -> String { const MINECRAFT_PROCESS_NAME: &str = "java"; struct StatusFromRcon { - players: Vec, - version: String, + players: Vec } fn get_status_from_rcon(rcon_password: &str) -> StatusFromRcon { @@ -104,20 +103,12 @@ fn get_status_from_rcon(rcon_password: &str) -> StatusFromRcon { println!("Error from 'list' command"); Vec::new() }, - }, - version: - match client.send_command("version".to_string()) { - Ok(resp) => resp.body, - Err(_e) => { - println!("Error from 'version' command"); - String::new() - } } } }, Err(_e) => { println!("Authentication error"); - StatusFromRcon { players: Vec::new(), version: String::new() } + StatusFromRcon { players: Vec::new() } }, }; @@ -159,7 +150,7 @@ pub fn get_minecraft_executable_information(world_path: &str, backup_path: &str, uptime: std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs() - process.start_time(), world_size, active_players: status_from_rcon.players, - version: status_from_rcon.version, + version: process.cmd()[process.cmd().len() - 2].clone(), // TODO: Extract the version from the .jar filename. last_backup: get_last_backup_datetime(backup_path) } )