From 26d8ecd93415beb2d4d11376972cdfe412a73301 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Fri, 6 May 2022 00:30:05 +0200 Subject: [PATCH] Get the version from the process command line (WIP) --- backend/src/minecraft_controller.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) 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) } ) -- 2.43.0