Initial commit: Brass & Sigil monorepo
Self-hosted Minecraft modpack distribution + administration system.
- launcher/ Avalonia 12 desktop client; single-file win-x64 publish.
Microsoft auth via XboxAuthNet, manifest+SHA-1 mod sync,
portable install path, sidecar settings.
- server/ brass-sigil-server daemon (.NET 8, linux-x64). Wraps the
MC subprocess, embedded Kestrel admin panel with cookie
auth + rate limiting, RCON bridge, scheduled backups,
BlueMap CLI integration with player markers + skin proxy,
friend-side whitelist request flow, world wipe with seed
selection (keep current / random / custom).
- pack/ pack.lock.json (Modrinth + manual CurseForge entries),
data-only tweak source under tweaks/, build outputs in
overrides/ (gitignored).
- scripts/ Build-Pack / Build-Tweaks / Update-Pack / Check-Updates
plus Deploy-Brass.ps1 unified one-shot deploy with
version-bump pre-flight and daemon-state detection.
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ModpackLauncher.Models;
|
||||
|
||||
public sealed class LauncherConfig
|
||||
{
|
||||
[JsonPropertyName("packName")]
|
||||
public string PackName { get; set; } = "Modpack";
|
||||
|
||||
[JsonPropertyName("manifestUrl")]
|
||||
public string ManifestUrl { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Subfolder name appended under the install location (sidecar exe folder
|
||||
/// by default, or the folder the user picked via "Change..."). Acts as
|
||||
/// a safety net so picking a generic location like "D:\" doesn't dump
|
||||
/// thousands of files at the drive root, and signals at a glance that
|
||||
/// this is the launcher's data, not the launcher itself.
|
||||
/// </summary>
|
||||
[JsonPropertyName("installDirName")]
|
||||
public string InstallDirName { get; set; } = "BrassAndSigilData";
|
||||
|
||||
[JsonPropertyName("memoryMB")]
|
||||
public int MemoryMB { get; set; } = 8192;
|
||||
|
||||
[JsonPropertyName("msalClientId")]
|
||||
public string MsalClientId { get; set; } = "";
|
||||
|
||||
/// <summary>Optional HTTP Basic auth username for the manifest URL and mod file URLs.</summary>
|
||||
[JsonPropertyName("httpUsername")]
|
||||
public string? HttpUsername { get; set; }
|
||||
|
||||
/// <summary>Optional HTTP Basic auth password (paired with HttpUsername).</summary>
|
||||
[JsonPropertyName("httpPassword")]
|
||||
public string? HttpPassword { get; set; }
|
||||
|
||||
public static LauncherConfig Load()
|
||||
{
|
||||
// 1. External override beside the exe (dev convenience / per-deploy override)
|
||||
var sidecar = Path.Combine(AppContext.BaseDirectory, "launcher-config.json");
|
||||
if (File.Exists(sidecar))
|
||||
{
|
||||
return ParseSafe(File.ReadAllText(sidecar));
|
||||
}
|
||||
|
||||
// 2. Embedded launcher-config.json (set at build time from local copy)
|
||||
var asm = typeof(LauncherConfig).Assembly;
|
||||
using (var stream = asm.GetManifestResourceStream("launcher-config.json"))
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
using var reader = new StreamReader(stream);
|
||||
return ParseSafe(reader.ReadToEnd());
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Fall back to embedded template (so fresh clones still run, with placeholders)
|
||||
using (var stream = asm.GetManifestResourceStream("launcher-config.template.json"))
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
using var reader = new StreamReader(stream);
|
||||
return ParseSafe(reader.ReadToEnd());
|
||||
}
|
||||
}
|
||||
|
||||
return new LauncherConfig();
|
||||
}
|
||||
|
||||
private static LauncherConfig ParseSafe(string json)
|
||||
{
|
||||
var opts = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
||||
return JsonSerializer.Deserialize<LauncherConfig>(json, opts) ?? new LauncherConfig();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolve the absolute install directory. The launcher behaves as a
|
||||
/// portable app: by default it installs alongside the exe in
|
||||
/// <c><exe-folder>/<InstallDirName>/</c>. The user can override
|
||||
/// via the "Change..." picker, which stores the chosen *parent* folder
|
||||
/// in <c>InstallDirOverride</c>; we then append <see cref="InstallDirName"/>
|
||||
/// to it (same safety reasoning as the default).
|
||||
///
|
||||
/// Smart-skip: if the parent path already ends in InstallDirName, we
|
||||
/// don't double up. Lets users re-pick their existing install folder
|
||||
/// (e.g. "D:\Games\BrassAndSigilData") without ending up at
|
||||
/// "D:\Games\BrassAndSigilData\BrassAndSigilData".
|
||||
/// </summary>
|
||||
public string GetInstallDir(string? overrideDir = null)
|
||||
{
|
||||
var parent = !string.IsNullOrWhiteSpace(overrideDir)
|
||||
? overrideDir!
|
||||
: AppContext.BaseDirectory;
|
||||
|
||||
var trimmed = parent.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
if (string.Equals(Path.GetFileName(trimmed), InstallDirName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return trimmed;
|
||||
}
|
||||
return Path.Combine(parent, InstallDirName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ModpackLauncher.Models;
|
||||
|
||||
public sealed class LauncherSettings
|
||||
{
|
||||
[JsonPropertyName("memoryMB")]
|
||||
public int? MemoryMB { get; set; }
|
||||
|
||||
[JsonPropertyName("installDirOverride")]
|
||||
public string? InstallDirOverride { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Settings live next to the launcher exe ("sidecar"), so each copy of
|
||||
/// the launcher has its own independent state. Drop the launcher in a
|
||||
/// new folder on a different machine, or alongside the existing one in
|
||||
/// a separate directory, and they remember their own install paths,
|
||||
/// memory choices, etc. Matches the portable-app convention.
|
||||
/// </summary>
|
||||
private static string FilePath
|
||||
=> Path.Combine(AppContext.BaseDirectory, "launcher-settings.json");
|
||||
|
||||
public static LauncherSettings Load()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(FilePath)) return new LauncherSettings();
|
||||
return JsonSerializer.Deserialize<LauncherSettings>(File.ReadAllText(FilePath))
|
||||
?? new LauncherSettings();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new LauncherSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllText(
|
||||
FilePath,
|
||||
JsonSerializer.Serialize(this, new JsonSerializerOptions { WriteIndented = true })
|
||||
);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// best-effort
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ModpackLauncher.Models;
|
||||
|
||||
public sealed class Manifest
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[JsonPropertyName("version")]
|
||||
public string? Version { get; set; }
|
||||
|
||||
[JsonPropertyName("minecraft")]
|
||||
public MinecraftSpec Minecraft { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("loader")]
|
||||
public LoaderSpec? Loader { get; set; }
|
||||
|
||||
[JsonPropertyName("files")]
|
||||
public List<ManifestFile> Files { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Optional. The launcher version that the modpack publisher expects clients
|
||||
/// to be running. If a client's assembly version is lower than this, the launcher
|
||||
/// surfaces a "newer version available" banner pointing at <see cref="LauncherUrl"/>.
|
||||
/// </summary>
|
||||
[JsonPropertyName("launcherVersion")]
|
||||
public string? LauncherVersion { get; set; }
|
||||
|
||||
/// <summary>Public download URL for the latest launcher (shown in the banner).</summary>
|
||||
[JsonPropertyName("launcherUrl")]
|
||||
public string? LauncherUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional. If present, the launcher writes this entry into the player's
|
||||
/// <c>servers.dat</c> on first install so the modpack's server appears in
|
||||
/// the multiplayer list automatically -- no copy-paste needed.
|
||||
/// </summary>
|
||||
[JsonPropertyName("defaultServer")]
|
||||
public DefaultServer? DefaultServer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional. Filename (in shaderpacks/) of a shader pack to enable by default
|
||||
/// for fresh installs. Existing installs with a different shader chosen are
|
||||
/// left alone -- this is a default, not a forced override.
|
||||
/// </summary>
|
||||
[JsonPropertyName("defaultShader")]
|
||||
public string? DefaultShader { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional. Public base URL of the brass-sigil-server admin panel (e.g.
|
||||
/// https://bns-admin.sijbers.uk). The launcher uses this to send whitelist
|
||||
/// requests on the player's behalf -- nothing else.
|
||||
/// </summary>
|
||||
[JsonPropertyName("panelUrl")]
|
||||
public string? PanelUrl { get; set; }
|
||||
}
|
||||
|
||||
public sealed class DefaultServer
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
[JsonPropertyName("ip")]
|
||||
public string Ip { get; set; } = "";
|
||||
}
|
||||
|
||||
public sealed class MinecraftSpec
|
||||
{
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; set; } = "";
|
||||
}
|
||||
|
||||
public sealed class LoaderSpec
|
||||
{
|
||||
/// <summary>"forge" | "fabric" | "neoforge" | "vanilla" (or null)</summary>
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; } = "vanilla";
|
||||
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; set; } = "";
|
||||
}
|
||||
|
||||
public sealed class ManifestFile
|
||||
{
|
||||
[JsonPropertyName("path")]
|
||||
public string Path { get; set; } = "";
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; } = "";
|
||||
|
||||
[JsonPropertyName("sha1")]
|
||||
public string? Sha1 { get; set; }
|
||||
|
||||
[JsonPropertyName("size")]
|
||||
public long? Size { get; set; }
|
||||
}
|
||||
|
||||
public sealed class PackVersionRecord
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[JsonPropertyName("version")]
|
||||
public string? Version { get; set; }
|
||||
|
||||
[JsonPropertyName("syncedAt")]
|
||||
public string? SyncedAt { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user