mirror of
https://github.com/RoyalnetworkTR/simple-launcher.git
synced 2026-09-25 01:39:49 +03:00
- Add Services/ServersDat.cs (self-contained big-endian NBT codec) to write/ merge .AthenaStudios/servers.dat so the Athena server auto-appears in the in-game Multiplayer list. Existing entries preserved, deduped by IP. - Write servers.dat on every launch (independent of auto-connect). - Add an auto-connect-on-launch user setting (LocalSettings.AutoConnectOnLaunch + Settings checkbox); effective server-join = backend AutoConnect AND the user setting, so players can opt out of auto-join. - Remove the account delete button from AccountsView: users keep their name slots; only admins delete via the web panel (backend now 403s the self-delete endpoint).
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Text.Json;
|
|
|
|
namespace OfflineMinecraftLauncher.Services;
|
|
|
|
/// <summary>
|
|
/// Cross-platform JSON settings (replaces the Windows-only Properties.Settings).
|
|
/// Stored at %APPDATA%/.AthenaStudios/settings.json (or the XDG equivalent on Linux).
|
|
/// </summary>
|
|
public class LocalSettings
|
|
{
|
|
public int MaxRamMb { get; set; } = 4096;
|
|
public int MinRamMb { get; set; } = 2048;
|
|
public string JavaPath { get; set; } = "";
|
|
public string JvmArguments { get; set; } = "";
|
|
public string EnabledOptionalMods { get; set; } = "";
|
|
public int SelectedAccountId { get; set; } = -1;
|
|
/// <summary>When true (default), the launcher auto-joins the server on launch
|
|
/// if the backend's AutoConnect is also on. The user can turn this off here.</summary>
|
|
public bool AutoConnectOnLaunch { get; set; } = true;
|
|
|
|
private static string Dir =>
|
|
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppConfig.AppDataFolder);
|
|
|
|
private static string FilePath => Path.Combine(Dir, "settings.json");
|
|
|
|
public static LocalSettings Load()
|
|
{
|
|
try
|
|
{
|
|
if (File.Exists(FilePath))
|
|
{
|
|
var s = JsonSerializer.Deserialize<LocalSettings>(File.ReadAllText(FilePath));
|
|
if (s != null) return s;
|
|
}
|
|
}
|
|
catch { /* fall through to defaults */ }
|
|
return new LocalSettings();
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
try
|
|
{
|
|
Directory.CreateDirectory(Dir);
|
|
File.WriteAllText(FilePath, JsonSerializer.Serialize(this, new JsonSerializerOptions { WriteIndented = true }));
|
|
}
|
|
catch { /* non-fatal */ }
|
|
}
|
|
}
|