style: remove redundant code narration
This commit is contained in:
1 parent
495f31778b
commit
783fb76f06
115 files changed
+19
-746
No files matched your search
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// data pack scanning backed by the same pack.mcmeta reader as resource packs.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use super::entry::ContentEntry;
|
||||
|
||||
@@ -55,7 +55,6 @@ pub struct ContentEntry {
|
||||
pub icon_lines: Option<Vec<Vec<IconCell>>>,
|
||||
}
|
||||
|
||||
// enable/disable by renaming the file with/without ".disabled" suffix.
|
||||
pub fn toggle_entry(entry: &ContentEntry) -> Result<(), std::io::Error> {
|
||||
toggle_entry_path(entry).map(drop)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// terminal icon rasterization shared by every content type and markdown.
|
||||
|
||||
// a single "pixel" in a terminal icon.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct IconCell {
|
||||
pub symbol: char,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// scanning and toggling instance content (mods, resource packs, shaders, worlds).
|
||||
// minecraft uses a ".disabled" suffix convention for disabled content, so this leans on that heavily.
|
||||
|
||||
pub mod datapacks;
|
||||
@@ -30,8 +29,6 @@ pub use worlds::{scan_one_world, scan_worlds};
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
// figures out if a file is enabled or disabled based on the ".disabled" suffix,
|
||||
// and strips the extension to get a clean stem name
|
||||
pub(crate) fn parse_enabled_stem(file_name: &str, ext: &str) -> Option<(bool, String)> {
|
||||
let disabled_ext = format!("{ext}.disabled");
|
||||
if let Some(stem) = file_name.strip_suffix(&disabled_ext) {
|
||||
@@ -43,7 +40,6 @@ pub(crate) fn parse_enabled_stem(file_name: &str, ext: &str) -> Option<(bool, St
|
||||
}
|
||||
}
|
||||
|
||||
// same idea but for directories, which don't have a file extension to strip
|
||||
pub(crate) fn parse_enabled_stem_dir(file_name: &str) -> (bool, String) {
|
||||
if let Some(stem) = file_name.strip_suffix(".disabled") {
|
||||
(false, stem.to_string())
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// mod scanning and loader-specific metadata extraction.
|
||||
// jar files are just zips, so it cracks them open looking for loader-specific
|
||||
// metadata (fabric.mod.json, quilt.mod.json, mods.toml, mcmod.info) to get
|
||||
// names, descriptions, and icons. if none of those work, falls back to common
|
||||
// root-level icon paths (logo.png, icon.png, pack.png) or just the filename.
|
||||
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -47,7 +41,6 @@ fn icon_path_from_value(value: &serde_json::Value) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
// quilt puts its metadata under a "metadata" sub-object
|
||||
#[derive(Deserialize, Default)]
|
||||
struct QuiltModJson {
|
||||
#[serde(default)]
|
||||
@@ -142,10 +135,6 @@ pub fn scan_mods(instances_dir: &Path, instance_name: &str) -> Vec<ContentEntry>
|
||||
entries
|
||||
}
|
||||
|
||||
// tries each loader's metadata file to extract name, description, and icon.
|
||||
// checks fabric.mod.json, quilt.mod.json, META-INF/mods.toml (forge),
|
||||
// META-INF/neoforge.mods.toml, and mcmod.info (legacy forge). if none of
|
||||
// those yield an icon, falls back to common root-level paths.
|
||||
fn read_mod_metadata(jar_path: &Path) -> (String, String, String, Option<Vec<u8>>) {
|
||||
let file = match std::fs::File::open(jar_path) {
|
||||
Ok(file) => file,
|
||||
@@ -197,7 +186,6 @@ fn read_mod_metadata(jar_path: &Path) -> (String, String, String, Option<Vec<u8>
|
||||
}
|
||||
}
|
||||
|
||||
// no recognized metadata at all, try common icon paths
|
||||
let icon_bytes = try_fallback_icons(&mut archive);
|
||||
tracing::trace!(
|
||||
"No recognized mod metadata in {}; fallback_icon={}",
|
||||
@@ -291,8 +279,6 @@ fn read_forge_toml_meta(
|
||||
Some((name, description, version, logo))
|
||||
}
|
||||
|
||||
// legacy forge mcmod.info is either a bare json array of mod entries
|
||||
// or an object with a "modList" key wrapping the array
|
||||
fn read_mcmod_info(
|
||||
archive: &mut zip::ZipArchive<std::fs::File>,
|
||||
) -> Option<(String, String, String, String)> {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// shared pack.mcmeta scanning for resource packs and shader packs.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// resource pack scanner backed by the shared pack.mcmeta reader.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use super::entry::ContentEntry;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// shader pack scanner backed by the shared pack.mcmeta reader.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use super::entry::ContentEntry;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// world save scanning. worlds are always directories (never zips) and store
|
||||
// their icon as icon.png. also computes an approximate size from top-level
|
||||
// files + region data so the user gets some sense of how chonky their world is.
|
||||
|
||||
use std::{fs::File, path::Path};
|
||||
|
||||
use flate2::read::GzDecoder;
|
||||
@@ -204,7 +200,6 @@ fn dir_size_approx(path: &Path) -> u64 {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check region folder too (main chunk data)
|
||||
let region = path.join("region");
|
||||
if let Ok(rd) = std::fs::read_dir(region) {
|
||||
for entry in rd.flatten() {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// creates OS-native shortcuts for launching instances directly:
|
||||
// .desktop files on linux, .bat on windows, .command on macos
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::instance::models::InstanceConfig;
|
||||
@@ -42,7 +39,6 @@ pub fn icon_path() -> Option<PathBuf> {
|
||||
dirs_next::data_dir().map(|d| d.join("rmcl").join("icon.svg"))
|
||||
}
|
||||
|
||||
// lazily writes the bundled svg icon to disk the first time a shortcut needs it
|
||||
fn ensure_icon() -> Option<PathBuf> {
|
||||
let path = icon_path()?;
|
||||
if std::fs::read(&path).ok().as_deref() == Some(ICON_BYTES) {
|
||||
@@ -229,7 +225,6 @@ fn quote_windows_arg(value: &str) -> String {
|
||||
quoted
|
||||
}
|
||||
|
||||
// replaces anything that isn't alphanumeric, dash, or underscore with _
|
||||
fn sanitize(name: &str) -> String {
|
||||
name.chars()
|
||||
.map(|c| {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// multimc / prism launcher instance import: mods and configs are bundled
|
||||
// in the zip. we install the game + loader normally, then extract the
|
||||
// archive contents over it.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use crate::feedback::progress;
|
||||
@@ -119,7 +115,6 @@ pub async fn execute_import(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// extracts everything under .minecraft/ from the archive into the instance dir
|
||||
fn extract_mmc_archive(
|
||||
archive_path: &Path,
|
||||
minecraft_dir: &Path,
|
||||
@@ -239,7 +234,6 @@ fn instance_name_from_cfg(path: &Path) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
// finds the prefix for the archive: empty for flat zips, "DirName/" for nested
|
||||
fn find_archive_prefix(archive: &zip::ZipArchive<std::fs::File>) -> String {
|
||||
for name in archive.file_names() {
|
||||
if name.ends_with("mmc-pack.json") {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// modpack importing: parses user input, detects pack format from zip contents,
|
||||
// builds a summary, and delegates the actual import to format-specific modules.
|
||||
|
||||
pub mod curseforge;
|
||||
pub mod mmc;
|
||||
pub mod mrpack;
|
||||
@@ -28,9 +25,6 @@ pub enum ImportInput {
|
||||
LocalFile(String),
|
||||
}
|
||||
|
||||
// figures out what the user gave us: a modrinth URL, a local pack file,
|
||||
// or just a project slug. accepts a pretty wide range of inputs so users
|
||||
// don't have to think about it.
|
||||
pub fn parse_import_input(input: &str) -> ImportInput {
|
||||
let input = input.trim();
|
||||
|
||||
@@ -78,8 +72,6 @@ pub struct ImportSummary {
|
||||
pub source: Option<crate::instance::ProviderProject>,
|
||||
}
|
||||
|
||||
// peeks inside a zip to figure out what format it is.
|
||||
// checks provider manifests first, then mmc-pack.json.
|
||||
pub fn detect_format(path: &Path) -> Result<PackFormat, String> {
|
||||
tracing::debug!("Detecting modpack format for {}", path.display());
|
||||
let file =
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// modrinth .mrpack import: parse the manifest, download all the mods,
|
||||
// and extract config/resource overrides from the zip
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -43,7 +40,6 @@ pub struct MrpackFile {
|
||||
pub file_size: u64,
|
||||
}
|
||||
|
||||
// .mrpack is just a zip with modrinth.index.json at the root
|
||||
pub fn parse_mrpack(path: &Path) -> Result<MrpackIndex, String> {
|
||||
tracing::debug!("Parsing .mrpack manifest from {}", path.display());
|
||||
let file = std::fs::File::open(path).map_err(|e| format!("Cannot open .mrpack: {e}"))?;
|
||||
@@ -63,8 +59,6 @@ pub fn parse_mrpack(path: &Path) -> Result<MrpackIndex, String> {
|
||||
Ok(index)
|
||||
}
|
||||
|
||||
// mrpack dependencies use keys like "fabric-loader", "forge", etc.
|
||||
// checks in priority order and returns the first match.
|
||||
pub fn loader_from_dependencies(
|
||||
deps: &HashMap<String, String>,
|
||||
) -> (Option<ModLoader>, Option<String>) {
|
||||
@@ -132,7 +126,6 @@ pub fn build_summary(path: &Path) -> Result<ImportSummary, String> {
|
||||
})
|
||||
}
|
||||
|
||||
// peek into the zip to count files under overrides/ and client-overrides/
|
||||
fn count_overrides(mrpack_path: &Path) -> Result<usize, String> {
|
||||
let file = std::fs::File::open(mrpack_path).map_err(|e| e.to_string())?;
|
||||
let archive = zip::ZipArchive::new(file).map_err(|e| e.to_string())?;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// java runtime discovery shared by launching, loader installation, and settings.
|
||||
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
path::{Path, PathBuf},
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// builds the full java command line and spawns minecraft as a child process.
|
||||
// handles classpath assembly, auth token injection, and log capture.
|
||||
// loader-specific patches live in submodules (e.g. patches.rs for lwjgl3ify).
|
||||
|
||||
pub(crate) mod parser;
|
||||
mod patches;
|
||||
|
||||
@@ -300,9 +296,6 @@ async fn migrate_legacy_loader_profile_if_needed(
|
||||
Ok(Some(refreshed))
|
||||
}
|
||||
|
||||
// resolved auth credentials passed into the launch-invocation builder.
|
||||
// keeping these as borrowed strs lets callers pass owned strings or string
|
||||
// slices without forcing allocation.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LaunchAuth<'a> {
|
||||
pub username: &'a str,
|
||||
@@ -312,9 +305,7 @@ pub struct LaunchAuth<'a> {
|
||||
pub user_type: &'a str,
|
||||
}
|
||||
|
||||
// everything the spawner needs to construct the java command. assembled by
|
||||
// build_launch_invocation, consumed by launch(). exposed so integration tests
|
||||
// can assert on the rendered invocation without spawning a real process.
|
||||
// Exposed so integration tests can inspect the invocation without spawning Java.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LaunchInvocation {
|
||||
pub java: String,
|
||||
@@ -368,11 +359,6 @@ fn validate_quick_play_world(minecraft_dir: &Path, world: &str) -> Result<(), La
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// builds a fully-resolved java invocation for the given instance. reads
|
||||
// meta.json and the loader profile from disk, migrates legacy formats if
|
||||
// needed (may hit Mojang to refetch), resolves inheritsFrom, applies
|
||||
// loader-specific patches, and renders all template arguments. all I/O
|
||||
// except auth resolution and process spawning happens here.
|
||||
pub async fn build_launch_invocation(
|
||||
config: &InstanceConfig,
|
||||
instances_dir: &Path,
|
||||
@@ -555,7 +541,6 @@ pub async fn build_launch_invocation(
|
||||
.collect::<Vec<_>>()
|
||||
.join(sep);
|
||||
|
||||
// java resolution: instance override > global setting > auto-detect
|
||||
let java = config
|
||||
.java_path
|
||||
.clone()
|
||||
@@ -739,10 +724,6 @@ fn finish_config_sync(
|
||||
}
|
||||
}
|
||||
|
||||
// resolves auth credentials, then builds the launch invocation and spawns
|
||||
// the java process. only thin wrapper logic lives here: token refresh,
|
||||
// process spawn, child supervision. all the heavy lifting (profile loading,
|
||||
// classpath assembly, template rendering) sits behind build_launch_invocation.
|
||||
pub async fn launch(
|
||||
config: &InstanceConfig,
|
||||
instances_dir: &Path,
|
||||
@@ -751,7 +732,6 @@ pub async fn launch(
|
||||
) -> Result<(), LaunchError> {
|
||||
let name = config.name.clone();
|
||||
|
||||
// resolve auth credentials, refreshing the microsoft token if needed.
|
||||
let mut account_store = crate::auth::AccountStore::load();
|
||||
let account =
|
||||
select_launch_account(&account_store.accounts, config.preferred_account.as_deref());
|
||||
@@ -919,8 +899,6 @@ pub async fn launch(
|
||||
let config_for_post_exit = config.clone();
|
||||
let invocation_for_post_exit = invocation.clone();
|
||||
|
||||
// spawn a background task to babysit the child process: capture stdout/stderr
|
||||
// into both the TUI log viewer and a timestamped log file on disk
|
||||
tokio::spawn(async move {
|
||||
use std::io::Write;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -1004,7 +982,6 @@ pub async fn launch(
|
||||
}
|
||||
drop(log_tx);
|
||||
|
||||
// wait for either the process to exit naturally or a kill signal from the TUI
|
||||
let (code, killed_by_user) = tokio::select! {
|
||||
_ = kill_rx => {
|
||||
tracing::info!("[{}] Kill requested, terminating process", name_for_task);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// live minecraft process log parser.
|
||||
//
|
||||
// disk launch logs stay raw, but the tui needs enough structure to color and
|
||||
// group output sanely. this parser keeps stdout/stderr as a hint, frames
|
||||
// multiline java/jvm/native bursts into events, then assigns a semantic level.
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// classpath and jvm patches for legacy forge on java 9+.
|
||||
// lwjgl3ify ships a patched launchwrapper and retrofuturabootstrap that
|
||||
// replace the old URLClassLoader-based launcher with one that works on
|
||||
// modern java. this module handles extracting those patches, building
|
||||
// the right --add-opens flags, and swapping out the broken log4j jars.
|
||||
// modern java.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -19,12 +17,6 @@ pub struct LwjglifyPatches {
|
||||
pub extra_args: Vec<String>,
|
||||
}
|
||||
|
||||
// checks if lwjgl3ify is present in the mods folder, and if so:
|
||||
// 1. extracts forge patches from the lwjgl3ify jar
|
||||
// 2. prepends them to the classpath so they shadow vanilla launchwrapper
|
||||
// 3. parses --add-opens from the patches manifest
|
||||
// 4. replaces log4j 2.0-beta9 with prism's patched builds
|
||||
// 5. returns the jvm args and overridden main class
|
||||
pub async fn apply(
|
||||
minecraft_dir: &Path,
|
||||
lib_dir: &Path,
|
||||
@@ -43,7 +35,6 @@ pub async fn apply(
|
||||
return None;
|
||||
}
|
||||
|
||||
// prepend so patched classes shadow vanilla launchwrapper
|
||||
classpath.insert(0, patches_dest.clone());
|
||||
|
||||
let mut jvm_args = parse_add_opens(&patches_dest).unwrap_or_default();
|
||||
@@ -214,7 +205,6 @@ fn add_lwjgl3(lib_dir: &Path, classpath: &mut Vec<PathBuf>) {
|
||||
insert_pos += 1;
|
||||
}
|
||||
|
||||
// natives
|
||||
let natives = if *module == "lwjgl" {
|
||||
lib_dir.join(format!(
|
||||
"org/lwjgl/lwjgl/3.3.3/lwjgl-3.3.3-{os_classifier}.jar"
|
||||
@@ -234,11 +224,8 @@ fn add_lwjgl3(lib_dir: &Path, classpath: &mut Vec<PathBuf>) {
|
||||
tracing::info!("Added {} LWJGL 3.3.3 jars to classpath", insert_pos - 1);
|
||||
}
|
||||
|
||||
// writes a log4j2.xml config that sets the root logger to INFO. this
|
||||
// prevents LaunchClassLoader's debug() call from ever firing, which
|
||||
// avoids the ThrowableProxy -> SecurityManager -> StackWalker infinite
|
||||
// recursion on java 24+. the config is written to .minecraft/ and
|
||||
// pointed to via -Dlog4j.configurationFile.
|
||||
// Suppresses LaunchClassLoader's debug() call to avoid the
|
||||
// ThrowableProxy -> SecurityManager -> StackWalker recursion on Java 24+.
|
||||
fn write_log4j_config(minecraft_dir: &Path, jvm_args: &mut Vec<String>) {
|
||||
let config_path = minecraft_dir.join(".rmcl-log4j2.xml");
|
||||
let config = r#"<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// fabric installation. the nice one: just fetch a profile json and download
|
||||
// the libraries. no java installer nonsense required.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// forge installation. modern forge runs a java installer, old forge (pre-1.13)
|
||||
// can't run headless so we extract the profile and libraries from the jar
|
||||
// directly. the installer jar gets cleaned up either way.
|
||||
// Old Forge installers cannot run headless, so their profiles and libraries
|
||||
// must be extracted from the jar instead.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
@@ -85,7 +84,6 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
let profile_filename = format!("forge-{game_version}-{loader_version}.json");
|
||||
|
||||
if has_legacy_install_profile(&installer_jar) {
|
||||
// old forge: no --installClient support, extract directly from jar
|
||||
tracing::debug!("Forge installer uses legacy install_profile.json path");
|
||||
if let Err(e) =
|
||||
install_forge_from_profile(client, &installer_jar, meta_dir, &profile_filename)
|
||||
@@ -95,7 +93,6 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
return Err(e);
|
||||
}
|
||||
} else {
|
||||
// modern forge: run the java installer
|
||||
let java_path = java_path.map(str::to_owned).unwrap_or_else(|| {
|
||||
crate::config::SETTINGS
|
||||
.read()
|
||||
@@ -110,7 +107,6 @@ impl ModLoaderInstaller for ForgeInstaller {
|
||||
return Err(InstallError::Installer(e));
|
||||
}
|
||||
|
||||
// extract the profile from what the installer just wrote to disk
|
||||
save_forge_profile(instance_dir, meta_dir, game_version, loader_version)
|
||||
.map_err(InstallError::Installer)?;
|
||||
}
|
||||
@@ -271,7 +267,6 @@ pub(crate) async fn install_forge_from_profile(
|
||||
InstallError::Installer(InstallerError::Profile("missing install.path".into()))
|
||||
})?;
|
||||
|
||||
// extract the universal jar to the correct maven location
|
||||
let universal_maven_path = crate::instance::loader::maven::maven_coord_to_path(
|
||||
install_path_coord,
|
||||
)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// maven coordinate handling shared by loader installation and launch profiles.
|
||||
|
||||
#[must_use]
|
||||
pub fn maven_coord_to_path(coord: &str) -> Option<String> {
|
||||
let parts: Vec<&str> = coord.split(':').collect();
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// mod loader installation. each loader (fabric, forge, neoforge, quilt, vanilla)
|
||||
// implements the same trait so the UI can treat them uniformly: pick game version,
|
||||
// pick loader version, install. the actual installation strategies differ wildly
|
||||
// though (fabric/quilt just download jars, forge/neoforge run a whole java installer).
|
||||
|
||||
mod fabric;
|
||||
pub mod forge;
|
||||
pub mod maven;
|
||||
@@ -83,8 +78,7 @@ pub trait ModLoaderInstaller: Send + Sync {
|
||||
}
|
||||
}
|
||||
|
||||
// writes raw profile JSON bytes to meta_dir/loader-profiles/<filename>.
|
||||
// callers that already have the upstream bytes (fabric/quilt http fetch,
|
||||
// Callers that already have the upstream bytes (fabric/quilt http fetch,
|
||||
// legacy forge versionInfo extract) use this directly to keep the on-disk
|
||||
// file byte-for-byte identical to the source.
|
||||
pub(crate) fn save_profile_bytes(
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// neoforge installation. same java installer dance as forge (they forked from it,
|
||||
// after all), just with different URLs and version naming.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// quilt installation. same clean approach as fabric (profile json + library
|
||||
// downloads). they're basically fabric's cooler sibling.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// per-launch log files stored under minecraft/logs/launches/
|
||||
// each launch gets its own timestamped file so you can go back and see what
|
||||
// crashed last tuesday at 3am
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// in-memory ring buffer for stdout/stderr from running mc instances.
|
||||
// capped at 2000 lines per instance so it doesn't eat all the RAM
|
||||
// if someone leaves a server running for a week. you're welcome.
|
||||
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// CRUD for instances: create, delete, rename, load, save.
|
||||
// creation is the heavy one since it downloads the game, assets, and libraries.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use chrono::Utc;
|
||||
@@ -94,7 +91,6 @@ impl InstanceManager {
|
||||
.create_inner(name, game_version, loader, loader_version, &instance_dir)
|
||||
.await;
|
||||
|
||||
// clean up on failure so there's no half-baked instance left around
|
||||
if result.is_err() {
|
||||
tracing::debug!(
|
||||
"Cleaning up incomplete instance '{}' after creation failed",
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// instance management: creation, launching, importing modpacks, and all the
|
||||
// bookkeeping that comes with pretending to be a real launcher
|
||||
|
||||
pub mod config_sync;
|
||||
pub mod content;
|
||||
pub mod desktop;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// core data types for an instance: what loader it uses, what version, memory
|
||||
// settings, etc. this is what gets persisted to instance.json
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// global tracking for running minecraft instances. everything is behind
|
||||
// Arc<Mutex<>> because the launch/monitor tasks live on separate tokio threads
|
||||
// and the TUI render loop needs to read state every frame.
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
// width/height are read from the actual image file so the TUI can show
|
||||
// dimensions. falls back to 1920x1080 if the file is corrupt or unreadable
|
||||
// because honestly, what else are you gonna pick
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ScreenshotEntry {
|
||||
pub name: String,
|
||||
@@ -44,7 +41,6 @@ pub fn scan_screenshots(instances_dir: &Path, instance_name: &str) -> Vec<Screen
|
||||
})
|
||||
.collect();
|
||||
|
||||
// sorted newest-first since minecraft names them with timestamps
|
||||
entries.sort_by(|a, b| b.name.cmp(&a.name));
|
||||
entries
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
use super::super::packs::extract_description;
|
||||
use serde_json::json;
|
||||
|
||||
// every case exercises a distinct match arm in extract_description.
|
||||
#[rstest::rstest]
|
||||
#[case::string(json!("Simple pack"), "Simple pack")]
|
||||
#[case::object_with_text(json!({"text": "Hello world"}), "Hello world")]
|
||||
|
||||
@@ -39,9 +39,6 @@ fn parse_mmc_pack_vanilla() {
|
||||
assert!(pack.loader().0.is_none());
|
||||
}
|
||||
|
||||
// builds an in-memory mmc-style pack zip and verifies that
|
||||
// extract_mmc_archive copies only the .minecraft/ subtree into the
|
||||
// destination, preserving relative paths and skipping siblings.
|
||||
#[test]
|
||||
fn extract_mmc_archive_copies_minecraft_subtree() {
|
||||
use std::io::Write;
|
||||
@@ -51,9 +48,6 @@ fn extract_mmc_archive_copies_minecraft_subtree() {
|
||||
let dest = tmp.path().join("instance/.minecraft");
|
||||
std::fs::create_dir_all(&dest).unwrap();
|
||||
|
||||
// Pack/ is the prefix; only .minecraft/ entries should land in dest.
|
||||
// mmc-style pack: a root dir "Pack/" wrapping the .minecraft tree
|
||||
// plus a sibling mmc-pack.json that should NOT be extracted.
|
||||
{
|
||||
let file = std::fs::File::create(&archive_path).unwrap();
|
||||
let mut zip = zip::ZipWriter::new(file);
|
||||
@@ -74,13 +68,11 @@ fn extract_mmc_archive_copies_minecraft_subtree() {
|
||||
|
||||
extract_mmc_archive(&archive_path, &dest).expect("extract");
|
||||
|
||||
// .minecraft/ entries must have been copied with their relative paths
|
||||
let options = std::fs::read(dest.join("options.txt")).expect("options.txt");
|
||||
assert_eq!(options, b"lang:en_us");
|
||||
let modjar = std::fs::read(dest.join("mods/test-mod.jar")).expect("mods/test-mod.jar");
|
||||
assert_eq!(modjar, b"jar-bytes");
|
||||
|
||||
// and the sibling outside .minecraft/ must not have been copied
|
||||
assert!(
|
||||
!dest.join("mmc-pack.json").exists(),
|
||||
"mmc-pack.json should not land in the instance dir"
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
use super::*;
|
||||
use std::io::Write;
|
||||
|
||||
// builds an in-memory zip with the given entries, writes it to tmp, and
|
||||
// returns the path. shared by parse_add_opens tests.
|
||||
fn make_zip(tmp: &Path, name: &str, entries: &[(&str, &[u8])]) -> PathBuf {
|
||||
let path = tmp.join(name);
|
||||
let file = std::fs::File::create(&path).unwrap();
|
||||
@@ -29,7 +27,6 @@ fn strip_replaced_libs_removes_dominated_prefixes() {
|
||||
PathBuf::from("/libs/commons-compress-1.4.1.jar"),
|
||||
PathBuf::from("/libs/commons-io-2.4.jar"),
|
||||
PathBuf::from("/libs/guava-15.0.jar"),
|
||||
// these stay
|
||||
PathBuf::from("/libs/log4j-core-2.0.jar"),
|
||||
PathBuf::from("/libs/guava-21.0.jar"),
|
||||
];
|
||||
@@ -130,8 +127,6 @@ fn add_lwjgl3_inserts_only_jars_that_exist() {
|
||||
let mut classpath = vec![PathBuf::from("/leading/forge-patches.jar")];
|
||||
add_lwjgl3(lib_dir, &mut classpath);
|
||||
|
||||
// forge-patches stays at index 0; lwjgl core is inserted at index 1.
|
||||
// none of the other modules existed so nothing else was added.
|
||||
assert_eq!(classpath[0], PathBuf::from("/leading/forge-patches.jar"));
|
||||
assert_eq!(classpath[1], core_jar);
|
||||
assert_eq!(classpath.len(), 2);
|
||||
|
||||
@@ -57,13 +57,6 @@ fn push_and_drain_last_played() {
|
||||
assert!(drained.iter().any(|(k, _)| k == "run_test_lp"));
|
||||
}
|
||||
|
||||
// Removed drain_empty_returns_empty: it relied on no other test pushing
|
||||
// to LAST_PLAYED between the two drain calls, which races with the
|
||||
// parallel push_and_drain_last_played test. The drain semantics are
|
||||
// already covered by push_and_drain_last_played, which asserts a
|
||||
// specific entry is present, and the empty-result path is exercised
|
||||
// implicitly any time drain runs after that test's cleanup.
|
||||
|
||||
#[test]
|
||||
fn send_kill_returns_false_for_missing() {
|
||||
assert!(!send_kill("run_never_registered_xyz"));
|
||||
@@ -74,7 +67,6 @@ fn register_and_send_kill() {
|
||||
let (tx, mut rx) = tokio::sync::oneshot::channel::<()>();
|
||||
register_kill("run_test_kill", tx);
|
||||
assert!(send_kill("run_test_kill"));
|
||||
// the kill signal itself must arrive, not just report success
|
||||
assert!(rx.try_recv().is_ok());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user