mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 03:25:56 +00:00
Merge integrate/manager-0.9.14 into preview: Custom Races V2, fast races switch, ports, realm names, V2 switches, MySQL options, scheduled restart
Versions stay the preview's. schemas/bots.json keeps the preview's own bot scaling settings (master brought the released ones a second time, as duplicate keys). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
fc8b18ef97
57 files changed
+11926
-255
No files matched your search
+105
-4
@@ -343,6 +343,8 @@ struct StatusView {
|
||||
observed: Observed,
|
||||
busy: bool,
|
||||
path_exists: bool,
|
||||
/// A scheduled restart is under way: a world that is down for a few minutes did not crash.
|
||||
scheduled_restart: bool,
|
||||
}
|
||||
|
||||
/// Where the Manager keeps its own state (server list, logs). `%LOCALAPPDATA%` on Windows, the XDG data folder elsewhere.
|
||||
@@ -552,9 +554,12 @@ async fn server_status(
|
||||
let root = path_of(&state, &id)?;
|
||||
let busy = state.busy.lock().map(|b| b.contains(&id)).unwrap_or(false);
|
||||
let path_exists = root.is_dir();
|
||||
let observed = tauri::async_runtime::spawn_blocking(move || {
|
||||
let (observed, scheduled_restart) = tauri::async_runtime::spawn_blocking(move || {
|
||||
let ports = layout::read_ports(&root);
|
||||
process::observe(&root, &ports)
|
||||
(
|
||||
process::observe(&root, &ports),
|
||||
coa_core::launcher::schedule::under_way(&root),
|
||||
)
|
||||
})
|
||||
.await
|
||||
.map_err(|e| Error::Invalid(e.to_string()))?;
|
||||
@@ -562,6 +567,7 @@ async fn server_status(
|
||||
observed,
|
||||
busy,
|
||||
path_exists,
|
||||
scheduled_restart,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1366,7 +1372,11 @@ async fn realm_select(
|
||||
let view = coa_core::realms::select(&root, mode)?;
|
||||
let (dir, meta) = install_meta(&root)?;
|
||||
if let Some(client) = meta.client_path {
|
||||
coa_core::client::sync_realm(std::path::Path::new(&client), &dir, view.active)?;
|
||||
coa_core::client::sync_realm_named(
|
||||
std::path::Path::new(&client),
|
||||
&dir,
|
||||
&coa_core::realm_names::for_mode(&root, view.active),
|
||||
)?;
|
||||
}
|
||||
if restart {
|
||||
let out = driver::run(&root, Verb::StartAll)?;
|
||||
@@ -1383,6 +1393,90 @@ async fn realm_select(
|
||||
result
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct RestartScheduleView {
|
||||
schedule: coa_core::launcher::schedule::RestartSchedule,
|
||||
/// The server ships the Rust world supervisor that carries out the schedule.
|
||||
supported: bool,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn restart_schedule(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
) -> std::result::Result<RestartScheduleView, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
blocking(move || {
|
||||
Ok(RestartScheduleView {
|
||||
schedule: coa_core::launcher::schedule::load(&root),
|
||||
supported: root.join("Scripts/coa-launcher.exe").is_file(),
|
||||
})
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
/// Restart the world every day at the owner's local time; the running supervisor reads it within a minute.
|
||||
#[tauri::command]
|
||||
async fn restart_schedule_save(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
schedule: coa_core::launcher::schedule::RestartSchedule,
|
||||
) -> std::result::Result<RestartScheduleView, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
let _guard = BusyGuard::acquire(&state, &id)?;
|
||||
blocking(move || {
|
||||
Ok(RestartScheduleView {
|
||||
schedule: coa_core::launcher::schedule::save(&root, &schedule)?,
|
||||
supported: root.join("Scripts/coa-launcher.exe").is_file(),
|
||||
})
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn mysql_custom(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
) -> std::result::Result<coa_core::launcher::render::CustomMysql, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
blocking(move || Ok(coa_core::launcher::render::read_custom_mysql(&root))).await
|
||||
}
|
||||
|
||||
/// The owner's own MySQL options (Settings/mysql-custom.ini); they apply at the next start of the database.
|
||||
#[tauri::command]
|
||||
async fn mysql_custom_save(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
text: String,
|
||||
) -> std::result::Result<coa_core::launcher::render::CustomMysql, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
let _guard = BusyGuard::acquire(&state, &id)?;
|
||||
blocking(move || coa_core::launcher::render::write_custom_mysql(&root, &text)).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn realm_names(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
) -> std::result::Result<Vec<coa_core::realm_names::RealmName>, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
blocking(move || coa_core::realm_names::list(&root)).await
|
||||
}
|
||||
|
||||
/// Rename a realm (`None` brings back its default name). The realm list changes at once when the database runs,
|
||||
/// and the linked game client selects the new name on the next Play.
|
||||
#[tauri::command]
|
||||
async fn realm_rename(
|
||||
state: State<'_, AppState>,
|
||||
id: String,
|
||||
realm_id: u32,
|
||||
name: Option<String>,
|
||||
) -> std::result::Result<Vec<coa_core::realm_names::RealmName>, UiError> {
|
||||
let root = path_of(&state, &id)?;
|
||||
let _guard = BusyGuard::acquire(&state, &id)?;
|
||||
blocking(move || coa_core::realm_names::rename(&root, realm_id, name.as_deref())).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn realm_simultaneous(
|
||||
state: State<'_, AppState>,
|
||||
@@ -2613,7 +2707,8 @@ async fn play(
|
||||
}
|
||||
blocking(move || {
|
||||
let mode = coa_core::realms::state(&root)?.active;
|
||||
if !coa_core::client::sync_realm(&client, &dir, mode)? {
|
||||
let realm = coa_core::realm_names::for_mode(&root, mode);
|
||||
if !coa_core::client::sync_realm_named(&client, &dir, &realm)? {
|
||||
return Err(Error::Invalid(
|
||||
"Close the game client before pressing Play so its selected realm can be updated."
|
||||
.into(),
|
||||
@@ -3590,6 +3685,12 @@ pub fn run() {
|
||||
realm_select,
|
||||
realm_simultaneous,
|
||||
realm_with_reborn,
|
||||
realm_names,
|
||||
realm_rename,
|
||||
mysql_custom,
|
||||
mysql_custom_save,
|
||||
restart_schedule,
|
||||
restart_schedule_save,
|
||||
check_database,
|
||||
repair_server,
|
||||
plugins_repair,
|
||||
|
||||
Reference in new issue
Block a user