From b33779e77d22fd677ee8bd2ac50761ba7b4e06c9 Mon Sep 17 00:00:00 2001 From: azures04 Date: Sun, 1 Feb 2026 20:15:54 +0100 Subject: [PATCH] Added a lot - Self contained runtime - Translated french to english - Fixed java path and url --- LentiaLauncher.csproj | 7 +++++++ src/main/Program.cs | 14 ++++++++++++-- src/main/core/Constants.cs | 2 +- src/main/core/auth/Yggdrasil.cs | 4 ++-- src/main/core/auth/oauth2/Discord.cs | 4 ++-- src/main/core/game/Assets.cs | 6 +++--- src/main/core/game/Java.cs | 6 ++---- src/main/core/game/Versions.cs | 4 ++-- src/main/core/game/extra/Forge.cs | 2 +- src/main/core/utils/File.cs | 1 + src/main/core/utils/Http.cs | 1 + src/main/utils/Settings.cs | 8 ++++---- src/main/utils/Window.cs | 1 - 13 files changed, 38 insertions(+), 22 deletions(-) diff --git a/LentiaLauncher.csproj b/LentiaLauncher.csproj index d150c65..f32fe11 100644 --- a/LentiaLauncher.csproj +++ b/LentiaLauncher.csproj @@ -8,6 +8,13 @@ LentiaLauncher ./src/resources/icon.ico false + Major + win-x64 + true + false + true + true + true diff --git a/src/main/Program.cs b/src/main/Program.cs index 4e22146..5e32e04 100644 --- a/src/main/Program.cs +++ b/src/main/Program.cs @@ -29,6 +29,7 @@ class Program { BrikPackage bpkg = new BrikPackage(Path.Combine(__dirname, "root.dat"), 66); List entries = bpkg.ListEntries(); var window = new PhotinoWindow() + .SetTitle("Lentia") .SetUseOsDefaultLocation(false) .SetUseOsDefaultSize(false) .SetContextMenuEnabled(false) @@ -232,6 +233,15 @@ class Program { case "launcher::game": try { await GenericFilesService.FetchAndSyncGenericFiles(gameRoot); + + MinecraftVersion version = await GameHelper.PrepareGame(new LaunchOptions { + Version = new LaunchOptions.VersionOptions { Number = "1.12.2", Type = "release" }, + ModLoader = LaunchOptions.ModLoaderType.Forge + }, gameRoot); + + string javaPath = await JavaHelper.GetJavaExecutablePath(version, gameRoot); + SettingsManager.Set("JavaPath", javaPath); + var options = new LaunchOptions { Version = new LaunchOptions.VersionOptions { Number = "1.12.2", @@ -241,13 +251,13 @@ class Program { Max = $"{SettingsManager.ReadSettings().Ram.Max}M", Min = "512M" }, + JavaPath = javaPath, ModLoader = LaunchOptions.ModLoaderType.Forge, CustomArgs = new List { $"-javaagent:{Path.Combine(gameRoot, LauncherConstants.AgentsPath.AuthlibInjector)}={LauncherConstants.Urls.YggdrasilServer}" } }; - MinecraftVersion version = await GameHelper.PrepareGame(options, gameRoot); - await JavaHelper.GetJavaExecutablePath(version, gameRoot); + GameHelper.Launch(version, _authenticatedPlayer!, gameRoot, options, (logLine) => { var logMessage = new { requestId = "game::log", diff --git a/src/main/core/Constants.cs b/src/main/core/Constants.cs index 8541bbf..a4ebbdb 100644 --- a/src/main/core/Constants.cs +++ b/src/main/core/Constants.cs @@ -7,8 +7,8 @@ namespace Lentia.Core.Constants { public const string MojangManifest = "https://launchermeta.mojang.com/mc/game/version_manifest_v2.json"; public const string YggdrasilServer = "https://yggdrasil.azures.fr/"; public const string MojangAuthServer = YggdrasilServer + "authserver"; - public const string ApiUrl = "https://lentia-api.azures.fr"; + public const string AllJavaRuntime = "https://launchermeta.mojang.com/v1/products/java-runtime/2ec0cc96c44e5a76b9c8b7c39df7210883d12871/all.json"; } public static class AgentsPath { diff --git a/src/main/core/auth/Yggdrasil.cs b/src/main/core/auth/Yggdrasil.cs index 1ad5b57..6e986a4 100644 --- a/src/main/core/auth/Yggdrasil.cs +++ b/src/main/core/auth/Yggdrasil.cs @@ -90,9 +90,9 @@ public class Authenticator { var data = await response.Content.ReadFromJsonAsync(); return data != null ? AuthResult.Ok(data) : AuthResult.Fail("Erreur de lecture des données."); } catch (HttpRequestException ex) { - return AuthResult.Fail($"Erreur réseau : {ex.Message}", "NETWORK_ERROR"); + return AuthResult.Fail($"Network error : {ex.Message}", "NETWORK_ERROR"); } catch (Exception ex) { - return AuthResult.Fail($"Erreur interne : {ex.Message}", "INTERNAL_ERROR"); + return AuthResult.Fail($"Internal error : {ex.Message}", "INTERNAL_ERROR"); } } } \ No newline at end of file diff --git a/src/main/core/auth/oauth2/Discord.cs b/src/main/core/auth/oauth2/Discord.cs index d2724e3..5435f57 100644 --- a/src/main/core/auth/oauth2/Discord.cs +++ b/src/main/core/auth/oauth2/Discord.cs @@ -40,12 +40,12 @@ public class Discord { var response = await HttpHelper.FetchAsync(url, HttpMethod.Get); if (response.IsSuccessStatusCode) { var data = await response.Content.ReadFromJsonAsync(); - return data != null ? AuthResult.Ok(data) : AuthResult.Fail("Erreur de lecture des données."); + return data != null ? AuthResult.Ok(data) : AuthResult.Fail("Data reading error."); } else { var errorData = await response.Content.ReadFromJsonAsync(); Console.WriteLine(await response.Content.ReadAsStringAsync()); return AuthResult.Fail( - errorData?.errorMessage ?? "Identifiants invalides.", + errorData?.errorMessage ?? "Invalid credentials.", errorData?.error, errorData?.cause ); diff --git a/src/main/core/game/Assets.cs b/src/main/core/game/Assets.cs index e67cfd3..6e62a9e 100644 --- a/src/main/core/game/Assets.cs +++ b/src/main/core/game/Assets.cs @@ -31,10 +31,10 @@ public class AssetsHelper { string json = await response.Content.ReadAsStringAsync(); var index = JsonSerializer.Deserialize(json, LauncherConstants._jsonOptions); - return index ?? throw new Exception("L'index des assets est vide ou invalide."); + return index ?? throw new Exception("The assets index is empty or invalid"); } - throw new Exception($"Impossible de récupérer l'index des assets : {response.StatusCode}"); + throw new Exception($"Assets index unavailable : {response.StatusCode}"); } public static async Task DownloadAssets(AssetsIndex index, string rootDir) { @@ -87,7 +87,7 @@ public class AssetsHelper { await FileHelper.DownloadFileAsync(url, localPath); } catch (Exception ex) { Console.WriteLine(url); - Console.WriteLine($"Échec : {hash} - {ex.Message}"); + Console.WriteLine($"Fail : {hash} - {ex.Message}"); } }); } diff --git a/src/main/core/game/Java.cs b/src/main/core/game/Java.cs index 116e593..0c338e6 100644 --- a/src/main/core/game/Java.cs +++ b/src/main/core/game/Java.cs @@ -69,15 +69,13 @@ public static class JavaHelper { } private static async Task DownloadJavaRuntime(string root, string platform, string component) { - string allJsonUrl = "https://piston-meta.mojang.com/v1/products/java-runtime/2ec0cc6c0dba9f635e09f3900331038590632291/all.json"; - - var allRuntimesResponse = await HttpHelper.FetchAsync(allJsonUrl); + var allRuntimesResponse = await HttpHelper.FetchAsync(LauncherConstants.Urls.AllJavaRuntime); allRuntimesResponse.EnsureSuccessStatusCode(); var allRuntimes = await allRuntimesResponse.Content.ReadFromJsonAsync(LauncherConstants._jsonOptions); if (!allRuntimes.TryGetProperty(platform, out var platformData) || !platformData.TryGetProperty(component, out var componentVersions)) { - throw new Exception($"Le runtime {component} n'est pas disponible pour {platform}"); + throw new Exception($"There is no {component} runtime for {platform}"); } string manifestUrl = componentVersions[0].GetProperty("manifest").GetProperty("url").GetString()!; diff --git a/src/main/core/game/Versions.cs b/src/main/core/game/Versions.cs index 3241734..a0258fa 100644 --- a/src/main/core/game/Versions.cs +++ b/src/main/core/game/Versions.cs @@ -212,9 +212,9 @@ public static class VersionsHelper { string jsonResponse = await response.Content.ReadAsStringAsync(); var version = JsonSerializer.Deserialize(jsonResponse, LauncherConstants._jsonOptions); - return version ?? throw new Exception("Impossible de lire les détails de la version."); + return version ?? throw new Exception("Version details data are unreadable."); } else { - throw new Exception($"Erreur lors de la récupération des détails : {response.StatusCode}"); + throw new Exception($"Error when getting version details: {response.StatusCode}"); } } diff --git a/src/main/core/game/extra/Forge.cs b/src/main/core/game/extra/Forge.cs index 60b5a62..09b6eca 100644 --- a/src/main/core/game/extra/Forge.cs +++ b/src/main/core/game/extra/Forge.cs @@ -24,7 +24,7 @@ public static class ForgeHelper { string promoKey = $"{mcVersion}-{(recommended ? "recommended" : "latest")}"; if (promoData?.Promos == null || !promoData.Promos.TryGetValue(promoKey, out string? buildVersion)) { - throw new Exception($"Version Forge introuvable pour {promoKey}"); + throw new Exception($"No forge version found for : {promoKey}"); } bool isModern = IsVersionModern(mcVersion); diff --git a/src/main/core/utils/File.cs b/src/main/core/utils/File.cs index a70053f..031fbe2 100644 --- a/src/main/core/utils/File.cs +++ b/src/main/core/utils/File.cs @@ -2,6 +2,7 @@ namespace Lentia.Core.Utils; public static class FileHelper { public static async Task DownloadFileAsync(string url, string destinationPath) { + Console.WriteLine($"Downloading file from {url} to {destinationPath}"); string? directory = Path.GetDirectoryName(destinationPath); if (!string.IsNullOrEmpty(directory)) { Directory.CreateDirectory(directory); diff --git a/src/main/core/utils/Http.cs b/src/main/core/utils/Http.cs index e861ff0..2aff97b 100644 --- a/src/main/core/utils/Http.cs +++ b/src/main/core/utils/Http.cs @@ -8,6 +8,7 @@ public static class HttpHelper { private static readonly HttpClient Http = new HttpClient(); public static async Task FetchAsync(string url, HttpMethod? method = null, object? body = null, Dictionary? headers = null) { + Console.WriteLine($"Fetching {url} using {method} method"); var request = new HttpRequestMessage(method ?? HttpMethod.Get, url); if (headers != null) { diff --git a/src/main/utils/Settings.cs b/src/main/utils/Settings.cs index 4a76bc1..8e42c8b 100644 --- a/src/main/utils/Settings.cs +++ b/src/main/utils/Settings.cs @@ -64,7 +64,7 @@ public static class SettingsManager { foreach (var k in keys) { var property = current.GetType().GetProperty(k); - if (property == null) throw new Exception($"Clé {k} introuvable."); + if (property == null) throw new Exception($"Key {k} not found."); current = property.GetValue(current)!; } @@ -85,7 +85,7 @@ public static class SettingsManager { var prop = current.GetType().GetProperty(properties[i], System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.IgnoreCase); - if (prop == null) throw new Exception($"Niveau '{properties[i]}' introuvable."); + if (prop == null) throw new Exception($"Level '{properties[i]}' not found."); var next = prop.GetValue(current); if (next == null) { @@ -99,14 +99,14 @@ public static class SettingsManager { System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.IgnoreCase); if (lastProp == null || !lastProp.CanWrite) - throw new Exception($"Propriété '{properties[^1]}' introuvable ou verrouillée."); + throw new Exception($"Property '{properties[^1]}' not found or locked."); object? convertedValue = Convert.ChangeType(value.ToString(), lastProp.PropertyType); lastProp.SetValue(current, convertedValue); WriteSettings(settings); } catch (Exception ex) { - Console.WriteLine($"[SettingsManager] Erreur Set sur '{path}': {ex.Message}"); + Console.WriteLine($"[SettingsManager] \"set\" Error on '{path}': {ex.Message}"); } } } \ No newline at end of file diff --git a/src/main/utils/Window.cs b/src/main/utils/Window.cs index 66f8c40..0b261db 100644 --- a/src/main/utils/Window.cs +++ b/src/main/utils/Window.cs @@ -69,7 +69,6 @@ public static class WindowHelper { Size loginSize = GetScaledSize(window, 310, 420); window - .SetTitle("Lentia") .SetIconFile(iconPath) .SetResizable(false) .SetSize(loginSize)