Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
gravit0 committed Sep 8, 2022
2 parents 0e24564 + e620e1b commit 44b7c25
Show file tree
Hide file tree
Showing 30 changed files with 662 additions and 347 deletions.
8 changes: 4 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.13'
version '2.1.0'
def mainClassName = "pro.gravit.launcher.client.JavaRuntimeModule"

task sourcesJar(type: Jar) {
Expand Down Expand Up @@ -57,9 +57,9 @@ repositories {
}

dependencies {
implementation "pro.gravit.launcher:launcher-core:5.2.11"
implementation "pro.gravit.launcher:launcher-ws-api:5.2.11"
implementation "pro.gravit.launcher:launcher-client-api:5.2.11"
implementation "pro.gravit.launcher:launcher-core:5.3.0"
implementation "pro.gravit.launcher:launcher-ws-api:5.3.0"
implementation "pro.gravit.launcher:launcher-client-api:5.3.0"
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
7 changes: 5 additions & 2 deletions compat/lang/runtime_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ runtime.scenes.serverinfo.minimizeTooltip=Hide launcher
runtime.scenes.serverinfo.deauthTooltip=Logout from your account
runtime.scenes.serverinfo.backTooltip=Back to server list menu
runtime.scenes.serverinfo.exitTooltip=Exit from launcher

runtime.scenes.serverinfo.javaalert.header=Compatible JRE/JDK not found
runtime.scenes.serverinfo.javaalert.description=Your computer does not have a compatible JRE/JDK build. The client cannot be launched.\nDownload and install JRE/JDK %d and restart the launcher
runtime.scenes.serverinfo.javaalert.lwjgl2.header=Compatible JRE/JDK not found
runtime.scenes.serverinfo.javaalert.lwjgl2.description=This client does not support running on ARM processors\nUse support for running x86_64 applications on your OS and install JRE/JDK %d for x86_64

###### Options ######
runtime.scenes.options.headingOptional=OPTIONAL MODS
Expand Down Expand Up @@ -162,4 +165,4 @@ runtime.scenes.update.phase.assets=Assets Update
runtime.scenes.update.phase.client=Client update
runtime.scenes.update.phase.launch=Starting client
runtime.scenes.update.reloadTooltip=Retry uploading files
runtime.scenes.update.cancelTooltip=Cancel attempt to download files
runtime.scenes.update.cancelTooltip=Cancel attempt to download files
7 changes: 5 additions & 2 deletions compat/lang/runtime_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ runtime.scenes.serverinfo.minimizeTooltip=Скрыть лаунчер
runtime.scenes.serverinfo.deauthTooltip=Выйти из под вашего аккаунта
runtime.scenes.serverinfo.backTooltip=Вернутся в меню выбора сервера
runtime.scenes.serverinfo.exitTooltip=Закрыть лаунчер

runtime.scenes.serverinfo.javaalert.header=Совместимая JRE/JDK не найдена
runtime.scenes.serverinfo.javaalert.description=На вашем компьютере отсутствует совместимая сборка JRE/JDK. Запуск клиента невозможен.\n Скачайте и установите JRE/JDK %d и перезапустите лаунчер
runtime.scenes.serverinfo.javaalert.lwjgl2.header=Совместимая JRE/JDK не найдена
runtime.scenes.serverinfo.javaalert.lwjgl2.description=Этот клиент не поддерживает запуск на ARM процессорах\nИспользуйте поддержку запуска x86_64 приложений на вашей ОС и установите JRE/JDK %d для x86_64

###### Options ######
runtime.scenes.options.headingOptional=ОПЦИОНАЛЬНЫЕ МОДЫ
Expand Down Expand Up @@ -163,4 +166,4 @@ runtime.scenes.update.phase.assets=Обновление файлов ассет
runtime.scenes.update.phase.client=Обновление файлов клиента
runtime.scenes.update.phase.launch=Запуск клиента
runtime.scenes.update.reloadTooltip=Повторить загрузку файлов
runtime.scenes.update.cancelTooltip=Отменить попытку загрузки файлов
runtime.scenes.update.cancelTooltip=Отменить попытку загрузки файлов
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
5 changes: 4 additions & 1 deletion runtime/runtime_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ runtime.scenes.serverinfo.minimizeTooltip=Hide launcher
runtime.scenes.serverinfo.deauthTooltip=Logout from your account
runtime.scenes.serverinfo.backTooltip=Back to server list menu
runtime.scenes.serverinfo.exitTooltip=Exit from launcher

runtime.scenes.serverinfo.javaalert.header=Compatible JRE/JDK not found
runtime.scenes.serverinfo.javaalert.description=Your computer does not have a compatible JRE/JDK build. The client cannot be launched.\nDownload and install JRE/JDK %d and restart the launcher
runtime.scenes.serverinfo.javaalert.lwjgl2.header=Compatible JRE/JDK not found
runtime.scenes.serverinfo.javaalert.lwjgl2.description=This client does not support running on ARM processors\nUse support for running x86_64 applications on your OS and install JRE/JDK %d for x86_64

###### Options ######
runtime.scenes.options.headingOptional=OPTIONAL MODS
Expand Down
5 changes: 4 additions & 1 deletion runtime/runtime_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ runtime.scenes.serverinfo.minimizeTooltip=\u0421\u043a\u0440\u044b\u0442\u044c \
runtime.scenes.serverinfo.deauthTooltip=\u0412\u044b\u0439\u0442\u0438 \u0438\u0437 \u043f\u043e\u0434 \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430
runtime.scenes.serverinfo.backTooltip=\u0412\u0435\u0440\u043d\u0443\u0442\u0441\u044f \u0432 \u043c\u0435\u043d\u044e \u0432\u044b\u0431\u043e\u0440\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430
runtime.scenes.serverinfo.exitTooltip=\u0417\u0430\u043a\u0440\u044b\u0442\u044c \u043b\u0430\u0443\u043d\u0447\u0435\u0440

runtime.scenes.serverinfo.javaalert.header=\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430\u044f JRE/JDK \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430
runtime.scenes.serverinfo.javaalert.description=\u041d\u0430 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 JRE/JDK. \u0417\u0430\u043f\u0443\u0441\u043a \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d.\n \u0421\u043a\u0430\u0447\u0430\u0439\u0442\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 JRE/JDK %d \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043b\u0430\u0443\u043d\u0447\u0435\u0440
runtime.scenes.serverinfo.javaalert.lwjgl2.header=\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0430\u044f JRE/JDK \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430
runtime.scenes.serverinfo.javaalert.lwjgl2.description=\u042d\u0442\u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u0430 ARM \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u0445\n\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 x86_64 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 \u0432\u0430\u0448\u0435\u0439 \u041e\u0421 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 JRE/JDK %d \u0434\u043b\u044f x86_64

###### Options ######
runtime.scenes.options.headingOptional=\u041e\u041f\u0426\u0418\u041e\u041d\u0410\u041b\u042c\u041d\u042b\u0415 \u041c\u041e\u0414\u042b
Expand Down
4 changes: 4 additions & 0 deletions runtime/scenes/login/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,8 @@
-fx-background-color: -fx-white;
}

#authRadio {
-fx-max-width: 99999;
}

/*-- DrLeonardo styles refactor --*/
36 changes: 18 additions & 18 deletions runtime/scenes/login/login.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<!-- DrLeonardo refactor -->

<Pane fx:id="loginPane" prefHeight="500.0" prefWidth="900.0" styleClass="transparent" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1">
<Pane fx:id="loginPane" prefHeight="500.0" prefWidth="900.0" styleClass="transparent" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1">
<Pane fx:id="layout" prefHeight="500.0" prefWidth="900.0" styleClass="transparent">

<!-- Вертикальная полоса -->
Expand Down Expand Up @@ -74,23 +74,23 @@
</Pane>

<!-- Способы авторизации -->
<ScrollPane id="authList" hbarPolicy="NEVER" layoutX="728.0" layoutY="368.0" vbarPolicy="NEVER">
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets bottom="5.0" top="5.0" />
</padding>
<content>
<VBox alignment="BOTTOM_LEFT" />
</content>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
<effect>
<Blend />
</effect>
</ScrollPane>
<VBox alignment="BOTTOM_LEFT" layoutX="728.0" layoutY="159.0" prefHeight="339.0" prefWidth="167.0">
<VBox id="authList">
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets bottom="5.0" top="5.0" />
</padding>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
<effect>
<Blend />
</effect>
</VBox>
</VBox>


<!-- Навбар -->
<Pane id="header" prefHeight="100.0" prefWidth="900.0">
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/pro/gravit/launcher/client/JavaRuntimeModule.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.gravit.launcher.client;

import javafx.stage.Stage;
import pro.gravit.launcher.LauncherEngine;
import pro.gravit.launcher.client.events.ClientEngineInitPhase;
import pro.gravit.launcher.client.events.ClientExitPhase;
Expand All @@ -18,6 +19,9 @@
import pro.gravit.utils.helper.LogHelper;

import javax.swing.*;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Base64;

public class JavaRuntimeModule extends LauncherModule {

Expand All @@ -26,7 +30,7 @@ public class JavaRuntimeModule extends LauncherModule {
private RuntimeProvider provider;

public JavaRuntimeModule() {
super(new LauncherModuleInfo("StdJavaRuntime", new Version(2, 0, 13, 1, Version.Type.STABLE),
super(new LauncherModuleInfo("StdJavaRuntime", new Version(2, 1, 0, 1, Version.Type.STABLE),
0, new String[]{}, new String[]{"runtime"}));
}

Expand Down Expand Up @@ -73,8 +77,13 @@ private void preGuiPhase(ClientPreGuiPhase phase) {
LauncherEngine.exitLauncher(0);
}
try {
JavaFXApplication.class.getMethod("init");
} catch (NoSuchMethodException exception) {
Method m = JavaFXApplication.class.getMethod(new String(Base64.getDecoder().decode("c3RhcnQ=")), Stage.class); // Fix proguard remapping
LogHelper.warning("Method %s", m.toGenericString());
if(Modifier.isAbstract(m.getModifiers())) {
throw new RuntimeException("Method start is abstract");
}
} catch (Exception exception) {
LogHelper.error(exception);
noInitMethodAlert();
LauncherEngine.exitLauncher(0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package pro.gravit.launcher.client;

import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.LauncherEngine;
import pro.gravit.launcher.client.events.ClientExitPhase;
import pro.gravit.launcher.client.gui.JavaFXApplication;
import pro.gravit.launcher.events.request.LauncherRequestEvent;
import pro.gravit.launcher.request.Request;
import pro.gravit.launcher.request.secure.GetSecureLevelInfoRequest;
import pro.gravit.launcher.request.secure.HardwareReportRequest;
Expand All @@ -13,19 +8,8 @@
import pro.gravit.utils.helper.*;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class RuntimeSecurityService {
private static final Path BINARY_PATH = IOHelper.getCodeSource(Launcher.class);
private static final Path C_BINARY_PATH = BINARY_PATH.resolveSibling(IOHelper.getFileName(BINARY_PATH) + ".tmp");
private final JavaFXApplication application;
private final Boolean[] waitObject = new Boolean[]{null};

Expand Down Expand Up @@ -107,56 +91,7 @@ public boolean getSecurityState() throws InterruptedException {
}
}

public void update(LauncherRequestEvent result) throws IOException {
List<String> args = new ArrayList<>(8);
args.add(IOHelper.resolveJavaBin(null).toString());
if (LogHelper.isDebugEnabled())
args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled())));
args.add("-jar");
args.add(BINARY_PATH.toString());
ProcessBuilder builder = new ProcessBuilder(args.toArray(new String[0]));
builder.inheritIO();
// Rewrite and start new instance
try {
LauncherEngine.modulesManager.invokeEvent(new ClientExitPhase(0));
if(Request.getRequestService() instanceof AutoCloseable) {
((AutoCloseable) Request.getRequestService()).close();
}
} catch (Throwable ignored) {
}
Files.deleteIfExists(C_BINARY_PATH);
if (result.binary != null) {
IOHelper.write(C_BINARY_PATH, result.binary);
} else {
URL url;
try {
url = new URL(result.url);
} catch (MalformedURLException e) {
throw new IOException(e);
}
URLConnection connection = url.openConnection();
try (InputStream in = connection.getInputStream()) {
IOHelper.transfer(in, C_BINARY_PATH);
}
}
if (Arrays.equals(SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, C_BINARY_PATH),
SecurityHelper.digest(SecurityHelper.DigestAlgorithm.MD5, BINARY_PATH)))
throw new IOException("Invalid update (launcher needs update, but link has old launcher), check LaunchServer config...");
//To StdJavaRuntimeProvider
//try (InputStream in = IOHelper.newInput(C_BINARY_PATH)) {
// IOHelper.transfer(in, BINARY_PATH);
//}
//Files.deleteIfExists(C_BINARY_PATH);
//builder.start();
StdJavaRuntimeProvider.launcherUpdateTempPath = C_BINARY_PATH;
StdJavaRuntimeProvider.processBuilder = builder;
}

public byte[] sign(byte[] data) {
return SecurityHelper.sign(data, JavaRuntimeModule.engine.privateKey);
}

public boolean isMayBeDownloadJava() {
return JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@

import javafx.application.Application;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.LauncherEngine;
import pro.gravit.launcher.client.gui.JavaFXApplication;
import pro.gravit.launcher.gui.RuntimeProvider;
import pro.gravit.launcher.utils.LauncherUpdater;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.LogHelper;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

public class StdJavaRuntimeProvider implements RuntimeProvider {
public static Path launcherUpdateTempPath;
public static ProcessBuilder processBuilder;
public static volatile Path updatePath;
private static final AtomicReference<StdJavaRuntimeProvider> INSTANCE = new AtomicReference<>();

public StdJavaRuntimeProvider() {
Expand All @@ -34,20 +39,23 @@ public void run(String[] args) {
LogHelper.debug("Start JavaFX Application");
Application.launch(JavaFXApplication.class, args);
LogHelper.debug("Post Application.launch method invoked");
if (launcherUpdateTempPath != null && processBuilder != null) {
if(updatePath != null) {
LauncherUpdater.nothing();
LauncherEngine.beforeExit(0);
Path target = IOHelper.getCodeSource(LauncherUpdater.class);
try {
Path BINARY_PATH = IOHelper.getCodeSource(Launcher.class);
try (InputStream in = IOHelper.newInput(launcherUpdateTempPath)) {
IOHelper.transfer(in, BINARY_PATH);
try(InputStream input = IOHelper.newInput(updatePath)) {
try(OutputStream output = IOHelper.newOutput(target)) {
IOHelper.transfer(input, output);
}
}
Files.deleteIfExists(launcherUpdateTempPath);
processBuilder.start();
} catch (Throwable e) {
Files.deleteIfExists(updatePath);
} catch (IOException e) {
LogHelper.error(e);
LauncherEngine.forceExit(-109);
}

LauncherUpdater.restart();
}
System.exit(0);
}

@Override
Expand Down
Loading

0 comments on commit 44b7c25

Please sign in to comment.