Skip to content

Commit

Permalink
Merge branch 'release/2.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
gravit0 committed Nov 16, 2021
2 parents 16279ff + a7f8738 commit 718e158
Show file tree
Hide file tree
Showing 19 changed files with 139 additions and 22 deletions.
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions compat/lang/runtime_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions compat/lang/runtime_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=Закрыть лаунчер
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions runtime/runtime_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions runtime/runtime_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/pro/gravit/launcher/client/JavaRuntimeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"}));
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -106,14 +105,15 @@ 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);
securityService = new RuntimeSecurityService(this);
skinManager = new SkinManager(this);
triggerManager = new TriggerManager(this);
javaService = new JavaService(this);
offlineService = new OfflineService(this);
pingService = new PingService();
registerCommands();
}
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class GuiModuleConfig {
public Map<String, String> 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();
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -45,6 +46,8 @@ public class RuntimeSettings extends UserSettings {
public String theme;
@LauncherNetworkAPI
public Map<UUID, ProfileSettings> profileSettings = new HashMap<>();
@LauncherNetworkAPI
public List<ClientProfile> profiles;

public static RuntimeSettings getDefault() {
RuntimeSettings runtimeSettings = new RuntimeSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.<Button>lookup(layout, "#close").setOnAction((e) -> {
try {
close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import pro.gravit.launcher.client.gui.scenes.login.LoginScene;
import pro.gravit.launcher.events.RequestEvent;
import pro.gravit.launcher.events.request.AuthRequestEvent;
import pro.gravit.launcher.request.RequestService;
import pro.gravit.launcher.request.WebSocketEvent;
import pro.gravit.launcher.request.websockets.ClientWebSocketService;
import pro.gravit.utils.helper.LogHelper;

public class GuiEventHandler implements ClientWebSocketService.EventHandler {
public class GuiEventHandler implements RequestService.EventHandler {
private final JavaFXApplication application;

public GuiEventHandler(JavaFXApplication application) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public void doInit() {
changeAuthAvailability(authAvailability);
addAuthAvailability(authAvailability);
}
if(this.authAvailability == null && auth.list.size() > 0) {
changeAuthAvailability(auth.list.get(0));
}
hideOverlay(0, (event) -> {
if (application.runtimeSettings.password != null && application.runtimeSettings.autoAuth)
contextHelper.runCallback(this::loginWithGui);
Expand Down Expand Up @@ -195,7 +198,7 @@ public <T extends WebSocketEvent> void processing(Request<T> request, String tex
processingEnabled = false;
};
try {
Request.service.request(request).thenAccept((result) -> {
application.service.request(request).thenAccept((result) -> {
onSuccess.accept(result);
processingOff.run();
}).exceptionally((exc) -> {
Expand Down Expand Up @@ -372,6 +375,7 @@ private void onSuccessLogin(SuccessAuth successAuth) {
public void onGetProfiles() {
processing(new ProfilesRequest(), application.getTranslation("runtime.overlay.processing.text.profiles"), (profiles) -> {
application.stateService.setProfilesResult(profiles);
application.runtimeSettings.profiles = profiles.profiles;
for (ClientProfile profile : profiles.profiles) {
application.triggerManager.process(profile, application.stateService.getOptionalView(profile));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private void doLaunchClient(Path assetDir, HashedDir assetHDir, Path clientDir,
clientDir.resolve("resourcepacks"), profile, application.stateService.getPlayerProfile(), view,
application.stateService.getAccessToken(), clientHDir, assetHDir, jvmHDir);
clientLauncherProcess.params.ram = profileSettings.ram;
clientLauncherProcess.params.offlineMode = application.offlineService.isOfflineMode();
if (clientLauncherProcess.params.ram > 0) {
clientLauncherProcess.jvmArgs.add("-Xms" + clientLauncherProcess.params.ram + 'M');
clientLauncherProcess.jvmArgs.add("-Xmx" + clientLauncherProcess.params.ram + 'M');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void reset() {
serverButtonCache.serverButton.setOnMouseClicked(handle);
});
try {
Request.service.request(new PingServerRequest()).thenAccept((event) -> {
application.service.request(new PingServerRequest()).thenAccept((event) -> {
if (event.serverMap != null) {
application.pingService.addReports(event.serverMap);
}
Expand Down
Loading

0 comments on commit 718e158

Please sign in to comment.