mirror of
https://git.ahines.net/joeyahines/Albatross.git
synced 2026-11-08 09:13:57 +00:00
Fixed chunk range for restore
+ A single chunk can now also be restored + clippy+fmt
This commit is contained in:
1 parent
5a403b4b64
commit
a7e2b260bc
5 files changed
+138
-35
No files matched your search
+26
-16
@@ -2,14 +2,16 @@ use std::path::PathBuf;
|
||||
use structopt::StructOpt;
|
||||
|
||||
mod backup;
|
||||
mod chunk_coordinate;
|
||||
mod config;
|
||||
mod discord;
|
||||
mod region;
|
||||
mod restore;
|
||||
|
||||
use crate::backup::{convert_backup_to_sp, do_backup};
|
||||
use crate::chunk_coordinate::ChunkCoordinate;
|
||||
use crate::config::AlbatrossConfig;
|
||||
use crate::restore::{restore_range_from_backup, restore_chunk_from_backup};
|
||||
use crate::restore::{restore_chunk_from_backup, restore_range_from_backup};
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(about = "Backup your Minecraft Server!")]
|
||||
@@ -50,8 +52,11 @@ enum SubCommand {
|
||||
/// Backup to restore from
|
||||
#[structopt(parse(from_os_str))]
|
||||
backup_path: PathBuf,
|
||||
/// Backup range can be a single chunk coordinate pair or a chunk range
|
||||
chunk_range: Vec<i32>,
|
||||
/// Chunk to backup
|
||||
chunk: ChunkCoordinate,
|
||||
/// Upper chunk range bound
|
||||
#[structopt(short, long)]
|
||||
upper_bound: Option<ChunkCoordinate>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -84,29 +89,34 @@ fn main() {
|
||||
server_directory,
|
||||
world_name,
|
||||
backup_path,
|
||||
chunk_range
|
||||
chunk,
|
||||
upper_bound,
|
||||
} => {
|
||||
println!("Starting restore");
|
||||
|
||||
let server_directory = match server_directory {
|
||||
Some(dir) => dir,
|
||||
None => cfg.backup.minecraft_dir
|
||||
None => cfg.backup.minecraft_dir,
|
||||
};
|
||||
|
||||
if chunk_range.len() > 2 {
|
||||
let lower_x = chunk_range[0];
|
||||
let lower_z = chunk_range[1];
|
||||
let upper_x = chunk_range[2];
|
||||
let upper_z = chunk_range[3];
|
||||
match restore_range_from_backup(world_name.as_str(), lower_x, upper_x, lower_z, upper_z, &backup_path, &server_directory) {
|
||||
if let Some(upper_bound) = upper_bound {
|
||||
match restore_range_from_backup(
|
||||
world_name.as_str(),
|
||||
chunk,
|
||||
upper_bound,
|
||||
&backup_path,
|
||||
&server_directory,
|
||||
) {
|
||||
Ok(count) => println!("Restored {} chunks!", count),
|
||||
Err(e) => println!("Error restoring backup: {:?}", e),
|
||||
};
|
||||
}
|
||||
else if chunk_range.len() == 2 {
|
||||
let x = chunk_range[0];
|
||||
let z = chunk_range[1];
|
||||
match restore_chunk_from_backup(world_name.as_str(), x, z, &backup_path, &server_directory) {
|
||||
} else {
|
||||
match restore_chunk_from_backup(
|
||||
world_name.as_str(),
|
||||
chunk,
|
||||
&backup_path,
|
||||
&server_directory,
|
||||
) {
|
||||
Ok(_) => println!("Restored chunk!"),
|
||||
Err(e) => println!("Error restoring backup: {:?}", e),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user