[FEATURE] BuildInParams

This commit is contained in:
Gravita 2025-06-22 18:08:24 +07:00
parent 68e2230d34
commit 04ecbfc14b
5 changed files with 39 additions and 2 deletions

View file

@ -170,6 +170,8 @@ public static LauncherEngine newInstance(boolean clientInstance, Class<? extends
}
public void start(String... args) throws Throwable {
var config = Launcher.getConfig();
config.apply();
//Launcher.modulesManager = new ClientModuleManager(this);
ClientPreGuiPhase event = new ClientPreGuiPhase(null);
LauncherEngine.modulesManager.invokeEvent(event);
@ -178,7 +180,7 @@ public void start(String... args) throws Throwable {
runtimeProvider.init(clientInstance);
//runtimeProvider.preLoad();
if (!Request.isAvailable()) {
String address = Launcher.getConfig().address;
String address = config.address;
LogHelper.debug("Start async connection to %s", address);
RequestService service;
try {

View file

@ -50,6 +50,7 @@ public static void initialize() throws Exception {
config.unlockSecret = DebugProperties.UNLOCK_SECRET;
Launcher.setConfig(config);
Launcher.applyLauncherEnv(DebugProperties.ENV);
config.apply();
LauncherEngine.modulesManager = new RuntimeModuleManager();
LauncherEngine.modulesManager.loadModule(new RuntimeLauncherCoreModule());
for (String moduleClassName : DebugProperties.MODULE_CLASSES) {

View file

@ -1,5 +1,6 @@
package pro.gravit.launcher.base;
import pro.gravit.launcher.core.BuildInParams;
import pro.gravit.launcher.core.LauncherInject;
import pro.gravit.launcher.core.LauncherInjectionConstructor;
import pro.gravit.launcher.core.LauncherTrustManager;
@ -8,6 +9,7 @@
import pro.gravit.launcher.core.serialize.HInput;
import pro.gravit.launcher.core.serialize.HOutput;
import pro.gravit.launcher.core.serialize.stream.StreamObject;
import pro.gravit.utils.Version;
import pro.gravit.utils.helper.JVMHelper;
import pro.gravit.utils.helper.LogHelper;
import pro.gravit.utils.helper.SecurityHelper;
@ -122,6 +124,12 @@ public LauncherConfig(String address, Map<String, byte[]> runtime, String projec
runtimeEncryptKey = null;
}
public void apply() {
Version version = Version.getVersion();
BuildInParams.setVersion(new Version(version.major, version.minor, version.patch, (int) buildNumber));
BuildInParams.setProjectName(projectName);
}
public static void initModules(LauncherModulesManager modulesManager) {
if(JVMHelper.JVM_VERSION >= 17) {
modulesClasses.addAll(ModernModulesClass.modulesClasses);

View file

@ -119,12 +119,14 @@ private static void realMain(String[] args) throws Throwable {
// Verify ClientLauncher sign and classpath
LogHelper.debug("Verifying ClientLauncher sign and classpath");
// Start client with WatchService monitoring
var config = Launcher.getConfig();
config.apply();
RequestService service;
if (params.offlineMode) {
service = ClientLauncherMethods.initOffline(modulesManager, params);
Request.setRequestService(service);
} else {
service = StdWebSocketService.initWebSockets(Launcher.getConfig().address).get();
service = StdWebSocketService.initWebSockets(config.address).get();
Request.setRequestService(service);
LogHelper.debug("Restore sessions");
Request.restore(false, false, true);

View file

@ -0,0 +1,24 @@
package pro.gravit.launcher.core;
import pro.gravit.utils.Version;
public class BuildInParams {
private static volatile Version version;
private static volatile String projectName;
public static Version getVersion() {
return version;
}
public static void setVersion(Version version) {
BuildInParams.version = version;
}
public static String getProjectName() {
return projectName;
}
public static void setProjectName(String projectName) {
BuildInParams.projectName = projectName;
}
}