diff --git a/build.gradle b/build.gradle index c012d814..624b0adc 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ javafx { sourceCompatibility = '1.8' targetCompatibility = '1.8' group 'pro.gravit.launcher' -version '2.0.5' +version '2.0.6' def mainClassName = "pro.gravit.launcher.client.JavaRuntimeModule" task sourcesJar(type: Jar) { @@ -52,12 +52,13 @@ repositories { url "https://oss.sonatype.org/content/repositories/snapshots" } mavenCentral() + mavenLocal() } dependencies { - implementation "pro.gravit.launcher:launcher-core:5.2.5" - implementation "pro.gravit.launcher:launcher-ws-api:5.2.5" - implementation "pro.gravit.launcher:launcher-client-api:5.2.5" + implementation "pro.gravit.launcher:launcher-core:5.2.6" + implementation "pro.gravit.launcher:launcher-ws-api:5.2.6" + implementation "pro.gravit.launcher:launcher-client-api:5.2.6" implementation "pro.gravit.utils.enfs:enfs:1.0.0-SNAPSHOT" implementation 'io.netty:netty-codec-http:4.1.67.Final' implementation 'com.github.oshi:oshi-core:5.8.1' diff --git a/compat/lang/runtime_en.properties b/compat/lang/runtime_en.properties index 56ee5a02..5a7af129 100644 --- a/compat/lang/runtime_en.properties +++ b/compat/lang/runtime_en.properties @@ -27,6 +27,10 @@ runtime.scenes.login.textLogin=You do not have an account? runtime.scenes.login.dialog2fa.header=Need 2FA Authorization runtime.scenes.login.dialog2fa.error=Two-Factor Error runtime.scenes.login.text-2fa=ENTER TWO-FACTOR CODE +runtime.offline.dialog.header=Connection error +runtime.offline.dialog.text=Launcher can not connect to the authorization server. Offline mode is not available +runtime.offline.notification.header=Offline mode +runtime.offline.notification.text=You cannot download new clients, log into servers and use online functions # Tooltips # runtime.scenes.login.langTooltip=Switch language runtime.scenes.login.exitTooltip=Exit from launcher diff --git a/compat/lang/runtime_ru.properties b/compat/lang/runtime_ru.properties index 28fc51bd..4affc38a 100644 --- a/compat/lang/runtime_ru.properties +++ b/compat/lang/runtime_ru.properties @@ -27,6 +27,10 @@ runtime.scenes.login.textLogin=У вас нет учетной записи? runtime.scenes.login.dialog2fa.header=Требуется 2FA Авторизация runtime.scenes.login.dialog2fa.error=Ошибка 2FA Авторизации runtime.scenes.login.text-2fa=ВВЕДИТЕ КОД ВТОРОГО ФАКТОРА ЗАЩИТЫ +runtime.offline.dialog.header=Ошибка соединения +runtime.offline.dialog.text=Лаунчер не может подключится к серверу авторизации. Оффлайн режим недоступен +runtime.offline.notification.header=Оффлайн режим +runtime.offline.notification.text=Вы не можете скачивать новые клиенты, авторизоваться на серверах и пользоваться онлайн функциями # Tooltips # runtime.scenes.login.langTooltip=Переключить языковой пакет runtime.scenes.login.exitTooltip=Закрыть лаунчер diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a0f7639f..fbce071a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/runtime/runtime_en.properties b/runtime/runtime_en.properties index 82465d92..4b2f26fd 100644 --- a/runtime/runtime_en.properties +++ b/runtime/runtime_en.properties @@ -27,6 +27,10 @@ runtime.scenes.login.textLogin=You do not have an account? runtime.scenes.login.dialog2fa.header=Need 2FA Authorization runtime.scenes.login.dialog2fa.error=Two-Factor Error runtime.scenes.login.text-2fa=ENTER TWO-FACTOR CODE +runtime.offline.dialog.header=Connection error +runtime.offline.dialog.text=Launcher can not connect to the authorization server. Offline mode is not available +runtime.offline.notification.header=Offline mode +runtime.offline.notification.text=You cannot download new clients, log into servers and use online functions # Tooltips # runtime.scenes.login.langTooltip=Switch language runtime.scenes.login.exitTooltip=Exit from launcher diff --git a/runtime/runtime_ru.properties b/runtime/runtime_ru.properties index 0e4b4b0d..7e0d9e72 100644 --- a/runtime/runtime_ru.properties +++ b/runtime/runtime_ru.properties @@ -27,6 +27,10 @@ runtime.scenes.login.textLogin=\u0423 \u0432\u0430\u0441 \u043d\u0435\u0442 \u04 runtime.scenes.login.dialog2fa.header=\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f 2FA \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f runtime.scenes.login.dialog2fa.error=\u041e\u0448\u0438\u0431\u043a\u0430 2FA \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 runtime.scenes.login.text-2fa=\u0412\u0412\u0415\u0414\u0418\u0422\u0415 \u041a\u041e\u0414 \u0412\u0422\u041e\u0420\u041e\u0413\u041e \u0424\u0410\u041a\u0422\u041e\u0420\u0410 \u0417\u0410\u0429\u0418\u0422\u042b +runtime.offline.dialog.header=\u041e\u0448\u0438\u0431\u043a\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f +runtime.offline.dialog.text=\u041b\u0430\u0443\u043d\u0447\u0435\u0440 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u041e\u0444\u0444\u043b\u0430\u0439\u043d \u0440\u0435\u0436\u0438\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d +runtime.offline.notification.header=\u041e\u0444\u0444\u043b\u0430\u0439\u043d \u0440\u0435\u0436\u0438\u043c +runtime.offline.notification.text=\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u044b, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043d\u043b\u0430\u0439\u043d \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 # Tooltips # runtime.scenes.login.langTooltip=\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043f\u0430\u043a\u0435\u0442 runtime.scenes.login.exitTooltip=\u0417\u0430\u043a\u0440\u044b\u0442\u044c \u043b\u0430\u0443\u043d\u0447\u0435\u0440 @@ -96,14 +100,14 @@ runtime.scenes.options.backTooltip=\u0412\u0435\u0440\u043d\u0443\u0442\u0441\u0 ###### Settings ###### runtime.scenes.settings.dirText=\u0421\u041c\u0415\u041d\u0418\u0422\u042c \u0414\u0418\u0420\u0415\u041a\u0422\u041e\u0420\u0418\u042e -runtime.scenes.settings.dirTitle=\u0421\u043C\u0435\u043D\u0438\u0442\u044C \u0434\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u044E \u0437\u0430\u0433\u0440\u0443\u0437\u043E\u043A +runtime.scenes.settings.dirTitle=\u0421\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043e\u043a runtime.scenes.settings.javaHeader=JAVA runtime.scenes.settings.javaError=JAVA \u041d\u0415\u0421\u041e\u0412\u041c\u0415\u0421\u0422\u0418\u041c\u0410 -runtime.scenes.settings.javaDesc=\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 Java, \u0441 \u043A\u043E\u0442\u043E\u0440\u043E\u0439 \u0432\u044B \u0445\u043E\u0442\u0438\u0442\u0435 \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C \u044D\u0442\u043E\u0442 \u043A\u043B\u0438\u0435\u043D\u0442 +runtime.scenes.settings.javaDesc=\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 Java, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442 runtime.scenes.settings.consoleTooltip=\u0421\u0438\u0441\u0442\u0435\u043c\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043b\u0430\u0443\u043d\u0447\u0435\u0440\u0430 runtime.scenes.settings.changedirTooltip=\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 -runtime.scenes.settings.ramAuto=\u0410\u0412\u0422\u041E -runtime.scenes.settings.ram={0} \u041C\u0411 +runtime.scenes.settings.ramAuto=\u0410\u0412\u0422\u041e +runtime.scenes.settings.ram={0} \u041c\u0411 # Properties # runtime.scenes.settings.properties.debug.name=Debug-\u0440\u0435\u0436\u0438\u043c runtime.scenes.settings.properties.debug.description=\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 diff --git a/src/main/java/pro/gravit/launcher/client/JavaRuntimeModule.java b/src/main/java/pro/gravit/launcher/client/JavaRuntimeModule.java index 120654b2..f8ffe991 100644 --- a/src/main/java/pro/gravit/launcher/client/JavaRuntimeModule.java +++ b/src/main/java/pro/gravit/launcher/client/JavaRuntimeModule.java @@ -5,10 +5,13 @@ import pro.gravit.launcher.client.events.ClientExitPhase; import pro.gravit.launcher.client.events.ClientPreGuiPhase; import pro.gravit.launcher.client.events.ClientUnlockConsoleEvent; +import pro.gravit.launcher.client.gui.service.OfflineService; import pro.gravit.launcher.gui.RuntimeProvider; import pro.gravit.launcher.modules.LauncherInitContext; import pro.gravit.launcher.modules.LauncherModule; import pro.gravit.launcher.modules.LauncherModuleInfo; +import pro.gravit.launcher.modules.events.OfflineModeEvent; +import pro.gravit.launcher.request.websockets.OfflineRequestService; import pro.gravit.utils.Version; import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.LogHelper; @@ -22,7 +25,7 @@ public class JavaRuntimeModule extends LauncherModule { private RuntimeProvider provider; public JavaRuntimeModule() { - super(new LauncherModuleInfo("StdJavaRuntime", new Version(2, 0, 5, 1, Version.Type.STABLE), + super(new LauncherModuleInfo("StdJavaRuntime", new Version(2, 0, 6, 1, Version.Type.STABLE), 0, new String[]{}, new String[]{"runtime"})); } @@ -53,6 +56,7 @@ public void init(LauncherInitContext initContext) { registerEvent(this::engineInitPhase, ClientEngineInitPhase.class); registerEvent(this::exitPhase, ClientExitPhase.class); registerEvent(this::consoleUnlock, ClientUnlockConsoleEvent.class); + registerEvent(this::offlineMode, OfflineModeEvent.class); } private void preGuiPhase(ClientPreGuiPhase phase) { @@ -72,6 +76,10 @@ private void consoleUnlock(ClientUnlockConsoleEvent event) { } } + private void offlineMode(OfflineModeEvent event) { + OfflineService.applyRuntimeProcessors((OfflineRequestService) event.service); + } + private void engineInitPhase(ClientEngineInitPhase initPhase) { JavaRuntimeModule.engine = initPhase.engine; } diff --git a/src/main/java/pro/gravit/launcher/client/RuntimeSecurityService.java b/src/main/java/pro/gravit/launcher/client/RuntimeSecurityService.java index 3f3f57b2..385daaea 100644 --- a/src/main/java/pro/gravit/launcher/client/RuntimeSecurityService.java +++ b/src/main/java/pro/gravit/launcher/client/RuntimeSecurityService.java @@ -115,7 +115,9 @@ public void update(LauncherRequestEvent result) throws IOException { // Rewrite and start new instance try { LauncherEngine.modulesManager.invokeEvent(new ClientExitPhase(0)); - Request.service.close(); + if(Request.getRequestService() instanceof AutoCloseable) { + ((AutoCloseable) Request.getRequestService()).close(); + } } catch (Throwable ignored) { } Files.deleteIfExists(C_BINARY_PATH); diff --git a/src/main/java/pro/gravit/launcher/client/gui/JavaFXApplication.java b/src/main/java/pro/gravit/launcher/client/gui/JavaFXApplication.java index 7cf15c98..f7eff894 100644 --- a/src/main/java/pro/gravit/launcher/client/gui/JavaFXApplication.java +++ b/src/main/java/pro/gravit/launcher/client/gui/JavaFXApplication.java @@ -17,10 +17,7 @@ import pro.gravit.launcher.client.gui.helper.EnFSHelper; import pro.gravit.launcher.client.gui.impl.*; import pro.gravit.launcher.client.gui.scenes.AbstractScene; -import pro.gravit.launcher.client.gui.service.JavaService; -import pro.gravit.launcher.client.gui.service.PingService; -import pro.gravit.launcher.client.gui.service.RuntimeDialogService; -import pro.gravit.launcher.client.gui.service.StateService; +import pro.gravit.launcher.client.gui.service.*; import pro.gravit.launcher.client.gui.stage.PrimaryStage; import pro.gravit.launcher.client.gui.utils.FXMLFactory; import pro.gravit.launcher.client.gui.utils.TriggerManager; @@ -29,6 +26,7 @@ import pro.gravit.launcher.managers.SettingsManager; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.request.Request; +import pro.gravit.launcher.request.RequestService; import pro.gravit.launcher.request.auth.AuthRequest; import pro.gravit.launcher.request.websockets.StdWebSocketService; import pro.gravit.utils.command.BaseCommandCategory; @@ -56,7 +54,7 @@ public class JavaFXApplication extends Application { public final LauncherConfig config = Launcher.getConfig(); public final ExecutorService workers = Executors.newWorkStealingPool(4); public RuntimeSettings runtimeSettings; - public StdWebSocketService service; + public RequestService service; public GuiObjectsContainer gui; public StateService stateService; public GuiModuleConfig guiModuleConfig; @@ -66,6 +64,7 @@ public class JavaFXApplication extends Application { public FXMLFactory fxmlFactory; public JavaService javaService; public PingService pingService; + public OfflineService offlineService; public TriggerManager triggerManager; private SettingsManager settingsManager; private PrimaryStage mainStage; @@ -106,7 +105,7 @@ public void init() throws Exception { runtimeSettings = (RuntimeSettings) settings.userSettings.get(JavaRuntimeModule.RUNTIME_NAME); runtimeSettings.apply(); DirBridge.dirUpdates = runtimeSettings.updatesDir == null ? DirBridge.defaultUpdatesDir : runtimeSettings.updatesDir; - service = Request.service; + service = Request.getRequestService(); service.registerEventHandler(new GuiEventHandler(this)); stateService = new StateService(); messageManager = new MessageManager(this); @@ -114,6 +113,7 @@ public void init() throws Exception { skinManager = new SkinManager(this); triggerManager = new TriggerManager(this); javaService = new JavaService(this); + offlineService = new OfflineService(this); pingService = new PingService(); registerCommands(); } @@ -163,6 +163,12 @@ public void start(Stage stage) throws Exception { DialogService.setDialogImpl(dialogService); DialogService.setNotificationImpl(dialogService); } + if(offlineService.isOfflineMode()) { + if(!offlineService.isAvailableOfflineMode() && !debugMode) { + messageManager.showDialog(getTranslation("runtime.offline.dialog.header"), getTranslation("runtime.offline.dialog.text"), Platform::exit, Platform::exit, false); + return; + } + } try { mainStage = new PrimaryStage(stage, String.format("%s Launcher", config.projectName)); // Overlay loading @@ -172,6 +178,9 @@ public void start(Stage stage) throws Exception { if (!IS_NOGUI.get()) { mainStage.setScene(gui.loginScene); mainStage.show(); + if(offlineService.isOfflineMode()) { + messageManager.createNotification(getTranslation("runtime.offline.notification.header"), getTranslation("runtime.offline.notification.text")); + } } else { Platform.setImplicitExit(false); } diff --git a/src/main/java/pro/gravit/launcher/client/gui/config/GuiModuleConfig.java b/src/main/java/pro/gravit/launcher/client/gui/config/GuiModuleConfig.java index 6e795e70..f8f93eee 100644 --- a/src/main/java/pro/gravit/launcher/client/gui/config/GuiModuleConfig.java +++ b/src/main/java/pro/gravit/launcher/client/gui/config/GuiModuleConfig.java @@ -18,6 +18,8 @@ public class GuiModuleConfig { public Map javaList; @LauncherInject(value = "modules.javaruntime.lazy") public boolean lazy; + @LauncherInject(value = "modules.javaruntime.disableofflinemode") + public boolean disableOfflineMode; public static Object getDefault() { GuiModuleConfig config = new GuiModuleConfig(); @@ -26,6 +28,7 @@ public static Object getDefault() { config.hastebinServer = "https://hastebin.com"; config.lazy = true; config.javaList = new HashMap<>(); + config.disableOfflineMode = false; return config; } } diff --git a/src/main/java/pro/gravit/launcher/client/gui/config/RuntimeSettings.java b/src/main/java/pro/gravit/launcher/client/gui/config/RuntimeSettings.java index c71acfa7..a74b5146 100644 --- a/src/main/java/pro/gravit/launcher/client/gui/config/RuntimeSettings.java +++ b/src/main/java/pro/gravit/launcher/client/gui/config/RuntimeSettings.java @@ -12,6 +12,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -45,6 +46,8 @@ public class RuntimeSettings extends UserSettings { public String theme; @LauncherNetworkAPI public Map profileSettings = new HashMap<>(); + @LauncherNetworkAPI + public List profiles; public static RuntimeSettings getDefault() { RuntimeSettings runtimeSettings = new RuntimeSettings(); diff --git a/src/main/java/pro/gravit/launcher/client/gui/dialogs/InfoDialog.java b/src/main/java/pro/gravit/launcher/client/gui/dialogs/InfoDialog.java index bb858ff9..078ac7eb 100644 --- a/src/main/java/pro/gravit/launcher/client/gui/dialogs/InfoDialog.java +++ b/src/main/java/pro/gravit/launcher/client/gui/dialogs/InfoDialog.java @@ -43,9 +43,9 @@ public String getName() { @Override protected void doInit() throws Exception { textHeader = LookupHelper.lookup(layout, "#headingDialog"); - //textDescription = LookupHelper.lookup(layout, "#textDialog"); + textDescription = LookupHelper.lookup(layout, "#dialogDescription"); textHeader.setText(header); - //textDescription.setText(text); + textDescription.setText(text); LookupHelper.