mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Техническая возможность использования своей JVM
This commit is contained in:
parent
8d7db40909
commit
ecb904035a
7 changed files with 48 additions and 3 deletions
|
@ -99,6 +99,8 @@ public static final class Config extends ConfigObject {
|
||||||
public final String whitelistRejectString;
|
public final String whitelistRejectString;
|
||||||
|
|
||||||
public final boolean genMappings;
|
public final boolean genMappings;
|
||||||
|
public final boolean isUsingWrapper;
|
||||||
|
public final boolean isDownloadJava;
|
||||||
|
|
||||||
public ListConfigEntry mirrors;
|
public ListConfigEntry mirrors;
|
||||||
public final String binaryName;
|
public final String binaryName;
|
||||||
|
@ -142,6 +144,9 @@ private Config(BlockConfigEntry block, Path coredir,LaunchServer server) {
|
||||||
binaryName = block.getEntryValue("binaryName", StringConfigEntry.class);
|
binaryName = block.getEntryValue("binaryName", StringConfigEntry.class);
|
||||||
projectName = block.hasEntry("projectName") ? block.getEntryValue("projectName", StringConfigEntry.class) : "Minecraft";
|
projectName = block.hasEntry("projectName") ? block.getEntryValue("projectName", StringConfigEntry.class) : "Minecraft";
|
||||||
compress = block.getEntryValue("compress", BooleanConfigEntry.class);
|
compress = block.getEntryValue("compress", BooleanConfigEntry.class);
|
||||||
|
|
||||||
|
isUsingWrapper = block.getEntryValue("isUsingWrapper", BooleanConfigEntry.class);
|
||||||
|
isDownloadJava = block.getEntryValue("isDownloadJava", BooleanConfigEntry.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,16 @@ public void setClientPort(int port) {
|
||||||
body.append(port);
|
body.append(port);
|
||||||
body.append(";");
|
body.append(";");
|
||||||
}
|
}
|
||||||
|
public void setUsingWrapper(boolean b) {
|
||||||
|
body.append("this.isUsingWrapper = ");
|
||||||
|
body.append(b ? "true" : "false");
|
||||||
|
body.append(";");
|
||||||
|
}
|
||||||
|
public void setDownloadJava(boolean b) {
|
||||||
|
body.append("this.isDownloadJava = ");
|
||||||
|
body.append(b ? "true" : "false");
|
||||||
|
body.append(";");
|
||||||
|
}
|
||||||
|
|
||||||
public ClassPool getPool() {
|
public ClassPool getPool() {
|
||||||
return pool;
|
return pool;
|
||||||
|
|
|
@ -174,6 +174,8 @@ private void stdBuild() throws IOException {
|
||||||
jaConfigurator.setProjectName(server.config.projectName);
|
jaConfigurator.setProjectName(server.config.projectName);
|
||||||
jaConfigurator.setSecretKey(SecurityHelper.randomStringAESKey());
|
jaConfigurator.setSecretKey(SecurityHelper.randomStringAESKey());
|
||||||
jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512));
|
jaConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512));
|
||||||
|
jaConfigurator.setUsingWrapper(server.config.isUsingWrapper);
|
||||||
|
jaConfigurator.setDownloadJava(server.config.isDownloadJava);
|
||||||
server.buildHookManager.registerAllClientModuleClass(jaConfigurator);
|
server.buildHookManager.registerAllClientModuleClass(jaConfigurator);
|
||||||
try (ZipInputStream input = new ZipInputStream(
|
try (ZipInputStream input = new ZipInputStream(
|
||||||
IOHelper.newInput(IOHelper.getResourceURL("Launcher.jar")))) {
|
IOHelper.newInput(IOHelper.getResourceURL("Launcher.jar")))) {
|
||||||
|
|
|
@ -7,6 +7,9 @@ authRateLimit: 2;
|
||||||
authRateLimitMilis: 5000;
|
authRateLimitMilis: 5000;
|
||||||
authRejectString: "Вы превысили лимит авторизаций. Подождите некоторое время перед повторной попыткой";
|
authRejectString: "Вы превысили лимит авторизаций. Подождите некоторое время перед повторной попыткой";
|
||||||
|
|
||||||
|
isUsingWrapper: true;
|
||||||
|
isDownloadJava: false;
|
||||||
|
|
||||||
# White list testers
|
# White list testers
|
||||||
whitelistRejectString: "Вас нет в белом списке";
|
whitelistRejectString: "Вас нет в белом списке";
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,10 @@ public void write(HOutput output) throws IOException {
|
||||||
private static final String SOCKET_HOST = "127.0.0.1";
|
private static final String SOCKET_HOST = "127.0.0.1";
|
||||||
private static final int SOCKET_PORT = Launcher.getConfig().clientPort;
|
private static final int SOCKET_PORT = Launcher.getConfig().clientPort;
|
||||||
private static final String MAGICAL_INTEL_OPTION = "-XX:HeapDumpPath=ThisTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump";
|
private static final String MAGICAL_INTEL_OPTION = "-XX:HeapDumpPath=ThisTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump";
|
||||||
private static final boolean isUsingWrapper = true;
|
private static final boolean isUsingWrapper = Launcher.getConfig().isUsingWrapper;
|
||||||
|
private static final boolean isDownloadJava = Launcher.getConfig().isDownloadJava;
|
||||||
|
|
||||||
|
private static Path JavaBinPath;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final Set<PosixFilePermission> BIN_POSIX_PERMISSIONS = Collections.unmodifiableSet(EnumSet.of(
|
private static final Set<PosixFilePermission> BIN_POSIX_PERMISSIONS = Collections.unmodifiableSet(EnumSet.of(
|
||||||
PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, // Owner
|
PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, // Owner
|
||||||
|
@ -227,6 +230,10 @@ private static void addClientArgs(Collection<String> args, ClientProfile profile
|
||||||
Collections.addAll(args, "--height", Integer.toString(params.height));
|
Collections.addAll(args, "--height", Integer.toString(params.height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@LauncherAPI
|
||||||
|
public static void setJavaBinPath(Path javaBinPath) {
|
||||||
|
JavaBinPath = javaBinPath;
|
||||||
|
}
|
||||||
|
|
||||||
private static void addClientLegacyArgs(Collection<String> args, ClientProfile profile, Params params) {
|
private static void addClientLegacyArgs(Collection<String> args, ClientProfile profile, Params params) {
|
||||||
args.add(params.pp.username);
|
args.add(params.pp.username);
|
||||||
|
@ -288,7 +295,6 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl
|
||||||
private static Process process = null;
|
private static Process process = null;
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public static Process launch(
|
public static Process launch(
|
||||||
|
|
||||||
SignedObjectHolder<HashedDir> assetHDir, SignedObjectHolder<HashedDir> clientHDir,
|
SignedObjectHolder<HashedDir> assetHDir, SignedObjectHolder<HashedDir> clientHDir,
|
||||||
SignedObjectHolder<ClientProfile> profile, Params params, boolean pipeOutput) throws Throwable {
|
SignedObjectHolder<ClientProfile> profile, Params params, boolean pipeOutput) throws Throwable {
|
||||||
// Write params file (instead of CLI; Mustdie32 API can't handle command line > 32767 chars)
|
// Write params file (instead of CLI; Mustdie32 API can't handle command line > 32767 chars)
|
||||||
|
@ -331,9 +337,17 @@ public static Process launch(
|
||||||
checkJVMBitsAndVersion();
|
checkJVMBitsAndVersion();
|
||||||
// Fill CLI arguments
|
// Fill CLI arguments
|
||||||
List<String> args = new LinkedList<>();
|
List<String> args = new LinkedList<>();
|
||||||
boolean wrapper = isUsingWrapper() && Launcher.isUsingAvanguard();
|
boolean wrapper = isUsingWrapper();
|
||||||
Path javaBin;
|
Path javaBin;
|
||||||
if (wrapper) javaBin = JVMHelper.JVM_BITS == 64 ? AvanguardStarter.wrap64 : AvanguardStarter.wrap32;
|
if (wrapper) javaBin = JVMHelper.JVM_BITS == 64 ? AvanguardStarter.wrap64 : AvanguardStarter.wrap32;
|
||||||
|
else if(isDownloadJava)
|
||||||
|
{
|
||||||
|
//Linux и Mac не должны скачивать свою JVM
|
||||||
|
if(JVMHelper.OS_TYPE == OS.MUSTDIE)
|
||||||
|
javaBin = IOHelper.resolveJavaBin(JavaBinPath);
|
||||||
|
else
|
||||||
|
javaBin = Paths.get(System.getProperty("java.home") + IOHelper.PLATFORM_SEPARATOR + "bin" + IOHelper.PLATFORM_SEPARATOR + "java");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
javaBin = Paths.get(System.getProperty("java.home") + IOHelper.PLATFORM_SEPARATOR + "bin" + IOHelper.PLATFORM_SEPARATOR + "java");
|
javaBin = Paths.get(System.getProperty("java.home") + IOHelper.PLATFORM_SEPARATOR + "bin" + IOHelper.PLATFORM_SEPARATOR + "java");
|
||||||
args.add(javaBin.toString());
|
args.add(javaBin.toString());
|
||||||
|
|
|
@ -6,6 +6,8 @@ public class AutogenConfig {
|
||||||
public int port;
|
public int port;
|
||||||
public int clientPort;
|
public int clientPort;
|
||||||
private boolean isInitModules;
|
private boolean isInitModules;
|
||||||
|
public boolean isUsingWrapper;
|
||||||
|
public boolean isDownloadJava; //Выставление этого флага требует модификации runtime части
|
||||||
public String secretKeyClient;
|
public String secretKeyClient;
|
||||||
|
|
||||||
AutogenConfig() {
|
AutogenConfig() {
|
||||||
|
|
|
@ -42,6 +42,9 @@ public static AutogenConfig getAutogenConfig() {
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public final Map<String, byte[]> runtime;
|
public final Map<String, byte[]> runtime;
|
||||||
|
|
||||||
|
public final boolean isUsingWrapper;
|
||||||
|
public final boolean isDownloadJava;
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException {
|
public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException {
|
||||||
String localAddress = config.address;
|
String localAddress = config.address;
|
||||||
|
@ -51,6 +54,8 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException
|
||||||
projectname = config.projectname;
|
projectname = config.projectname;
|
||||||
clientPort = config.clientPort;
|
clientPort = config.clientPort;
|
||||||
secretKeyClient = config.secretKeyClient;
|
secretKeyClient = config.secretKeyClient;
|
||||||
|
isDownloadJava = config.isDownloadJava;
|
||||||
|
isUsingWrapper = config.isUsingWrapper;
|
||||||
// Read signed runtime
|
// Read signed runtime
|
||||||
int count = input.readLength(0);
|
int count = input.readLength(0);
|
||||||
Map<String, byte[]> localResources = new HashMap<>(count);
|
Map<String, byte[]> localResources = new HashMap<>(count);
|
||||||
|
@ -75,6 +80,8 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map<Stri
|
||||||
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
||||||
this.projectname = projectname;
|
this.projectname = projectname;
|
||||||
this.clientPort = 32148;
|
this.clientPort = 32148;
|
||||||
|
isUsingWrapper = true;
|
||||||
|
isDownloadJava = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
@ -85,6 +92,8 @@ public LauncherConfig(String address, int port, RSAPublicKey publicKey, Map<Stri
|
||||||
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
|
||||||
this.projectname = "Minecraft";
|
this.projectname = "Minecraft";
|
||||||
this.clientPort = 32148;
|
this.clientPort = 32148;
|
||||||
|
isUsingWrapper = true;
|
||||||
|
isDownloadJava = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue