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=545e8c228a3ded8038ea12653ca12f31051066f8;hp=54143e8639cd11c3c4ddda13b1310a668d4dbed1;hb=3c7277e35a204d40d9e72794503a68530fcec682;hpb=c849abb7645a38c4fcb91222b399f0914287527a diff --git a/backend/src/minecraft_controller.rs b/backend/src/minecraft_controller.rs index 54143e8..545e8c2 100644 --- a/backend/src/minecraft_controller.rs +++ b/backend/src/minecraft_controller.rs @@ -9,6 +9,7 @@ pub struct MinecraftExe { uptime: u64, // [s]. world_size: u64, // [B]. active_players: Vec, + version: String, last_backup: Option, } @@ -40,6 +41,10 @@ impl MinecraftExe { } } + pub fn format_version(&self) -> String { + self.version.clone() + } + pub fn format_last_backup(&self) -> String { match self.last_backup { Some(t) => { @@ -73,6 +78,7 @@ const MINECRAFT_PROCESS_NAME: &str = "java"; struct StatusFromRcon { players: Vec, + version: String, } fn get_status_from_rcon(rcon_password: &str) -> StatusFromRcon { @@ -98,12 +104,20 @@ fn get_status_from_rcon(rcon_password: &str) -> StatusFromRcon { println!("Error from 'list' command"); Vec::new() }, + }, + version: + match client.send_command("list".to_string()) { + Ok(resp) => resp.body, + Err(_e) => { + println!("Error from 'version' command"); + String::new() + } } } }, Err(_e) => { println!("Authentication error"); - StatusFromRcon { players: Vec::new() } + StatusFromRcon { players: Vec::new(), version: String::new() } }, }; @@ -145,6 +159,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, last_backup: get_last_backup_datetime(backup_path) } )