mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FEATURE] optionalJVMArgs, optionalClientArgs и optionalClassPath
This commit is contained in:
parent
076dac6a84
commit
98b7aac9fd
14 changed files with 137 additions and 2 deletions
|
@ -38,5 +38,8 @@
|
|||
"--tweakClass", "net.minecraftforge.fml.common.launcher.FMLTweaker",
|
||||
"--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker"
|
||||
],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -38,5 +38,8 @@
|
|||
"--tweakClass", "net.minecraftforge.fml.common.launcher.FMLTweaker",
|
||||
"--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker"
|
||||
],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -38,5 +38,8 @@
|
|||
"--tweakClass", "net.minecraftforge.fml.common.launcher.FMLTweaker",
|
||||
"--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker"
|
||||
],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -36,5 +36,8 @@
|
|||
"classPath": ["forge.jar", "liteloader.jar", "minecraft.jar", "libraries"],
|
||||
"clientArgs": [
|
||||
],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -36,5 +36,8 @@
|
|||
"classPath": ["forge.jar", "liteloader.jar", "minecraft.jar", "libraries"],
|
||||
"clientArgs": [
|
||||
],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -31,5 +31,8 @@
|
|||
],
|
||||
"classPath": ["minecraft.jar", "libraries"],
|
||||
"clientArgs": [],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -31,5 +31,8 @@
|
|||
],
|
||||
"classPath": ["minecraft.jar", "libraries"],
|
||||
"clientArgs": [],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -36,5 +36,8 @@
|
|||
"--tweakClass", "cpw.mods.fml.common.launcher.FMLTweaker",
|
||||
"--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker"
|
||||
],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -34,5 +34,8 @@
|
|||
"--tweakClass", "cpw.mods.fml.common.launcher.FMLTweaker",
|
||||
"--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker"
|
||||
],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -34,5 +34,8 @@
|
|||
"--tweakClass", "cpw.mods.fml.common.launcher.FMLTweaker",
|
||||
"--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker"
|
||||
],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -34,5 +34,8 @@
|
|||
"--tweakClass", "net.minecraftforge.fml.common.launcher.FMLTweaker",
|
||||
"--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker"
|
||||
],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -34,5 +34,8 @@
|
|||
"--tweakClass", "net.minecraftforge.fml.common.launcher.FMLTweaker",
|
||||
"--tweakClass", "com.mumfrey.liteloader.launch.LiteLoaderTweaker"
|
||||
],
|
||||
"optionalJVMArgs": [],
|
||||
"optionalClientArgs": [],
|
||||
"optionalClassPath": [],
|
||||
"whitelist": []
|
||||
}
|
|
@ -69,6 +69,10 @@ public static final class Params extends StreamObject {
|
|||
@LauncherAPI
|
||||
public final Set<ClientProfile.OptionalFile> updateOptional;
|
||||
@LauncherAPI
|
||||
public final Set<ClientProfile.OptionalArgs> optionalClientArgs;
|
||||
@LauncherAPI
|
||||
public final Set<ClientProfile.OptionalArgs> optionalClassPath;
|
||||
@LauncherAPI
|
||||
public final String accessToken;
|
||||
@LauncherAPI
|
||||
public final boolean autoEnter;
|
||||
|
@ -89,9 +93,19 @@ public Params(byte[] launcherDigest, Path assetDir, Path clientDir, PlayerProfil
|
|||
boolean autoEnter, boolean fullScreen, int ram, int width, int height) {
|
||||
this.launcherDigest = launcherDigest.clone();
|
||||
this.updateOptional = new HashSet<>();
|
||||
this.optionalClientArgs = new HashSet<>();
|
||||
this.optionalClassPath = new HashSet<>();
|
||||
for (ClientProfile.OptionalFile s : Launcher.profile.getOptional()) {
|
||||
if (s.mark) updateOptional.add(s);
|
||||
}
|
||||
for(ClientProfile.OptionalArgs s : Launcher.profile.getOptionalClientArgs())
|
||||
{
|
||||
if(s.mark) optionalClientArgs.add(s);
|
||||
}
|
||||
for(ClientProfile.OptionalArgs s : Launcher.profile.getOptionalClassPath())
|
||||
{
|
||||
if(s.mark) optionalClassPath.add(s);
|
||||
}
|
||||
// Client paths
|
||||
this.assetDir = assetDir;
|
||||
this.clientDir = clientDir;
|
||||
|
@ -114,9 +128,29 @@ public Params(HInput input) throws Exception {
|
|||
assetDir = IOHelper.toPath(input.readString(0));
|
||||
clientDir = IOHelper.toPath(input.readString(0));
|
||||
updateOptional = new HashSet<>();
|
||||
optionalClientArgs = new HashSet<>();
|
||||
optionalClassPath = new HashSet<>();
|
||||
int len = input.readLength(128);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
updateOptional.add(new ClientProfile.OptionalFile(input.readString(512), true));
|
||||
String file = input.readString(512);
|
||||
boolean mark = input.readBoolean();
|
||||
updateOptional.add(new ClientProfile.OptionalFile(file, mark));
|
||||
}
|
||||
len = input.readLength(256);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int len2 = input.readLength(16);
|
||||
boolean mark = input.readBoolean();
|
||||
String[] optArgs = new String[len];
|
||||
for(int j=0;j<len2;++j) optArgs[j] = input.readString(512);
|
||||
optionalClientArgs.add(new ClientProfile.OptionalArgs(optArgs, mark));
|
||||
}
|
||||
len = input.readLength(256);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int len2 = input.readLength(16);
|
||||
boolean mark = input.readBoolean();
|
||||
String[] optArgs = new String[len];
|
||||
for(int j=0;j<len2;++j) optArgs[j] = input.readString(512);
|
||||
optionalClassPath.add(new ClientProfile.OptionalArgs(optArgs, mark));
|
||||
}
|
||||
// Client params
|
||||
pp = new PlayerProfile(input);
|
||||
|
@ -140,6 +174,21 @@ public void write(HOutput output) throws IOException {
|
|||
output.writeLength(updateOptional.size(), 128);
|
||||
for (ClientProfile.OptionalFile s : updateOptional) {
|
||||
output.writeString(s.file, 512);
|
||||
output.writeBoolean(s.mark);
|
||||
}
|
||||
output.writeLength(optionalClientArgs.size(),256);
|
||||
for(ClientProfile.OptionalArgs s : optionalClientArgs)
|
||||
{
|
||||
output.writeLength(s.args.length,16);
|
||||
output.writeBoolean(s.mark);
|
||||
for(String f : s.args) output.writeString(f,512);
|
||||
}
|
||||
output.writeLength(optionalClassPath.size(),256);
|
||||
for(ClientProfile.OptionalArgs s : optionalClassPath)
|
||||
{
|
||||
output.writeLength(s.args.length,16);
|
||||
output.writeBoolean(s.mark);
|
||||
for(String f : s.args) output.writeString(f,512);
|
||||
}
|
||||
// Client params
|
||||
pp.write(output);
|
||||
|
@ -229,7 +278,10 @@ private static void addClientArgs(Collection<String> args, ClientProfile profile
|
|||
Collections.addAll(args, "--server", profile.getServerAddress());
|
||||
Collections.addAll(args, "--port", Integer.toString(profile.getServerPort()));
|
||||
}
|
||||
|
||||
for(ClientProfile.OptionalArgs optionalArgs : params.optionalClientArgs)
|
||||
{
|
||||
if(optionalArgs.mark) Collections.addAll(args,optionalArgs.args);
|
||||
}
|
||||
// Add window size args
|
||||
if (params.fullScreen)
|
||||
Collections.addAll(args, "--fullscreen", Boolean.toString(true));
|
||||
|
@ -375,6 +427,13 @@ public static Process launch(
|
|||
// Add classpath and main class
|
||||
String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString();
|
||||
Collections.addAll(args, profile.getJvmArgs());
|
||||
if(profile.getOptionalJVMArgs() != null)
|
||||
{
|
||||
for(ClientProfile.OptionalArgs addArgs : profile.getOptionalJVMArgs())
|
||||
{
|
||||
if(addArgs.mark) Collections.addAll(args,addArgs.args);
|
||||
}
|
||||
}
|
||||
Collections.addAll(args, "-Djava.library.path=".concat(params.clientDir.resolve(NATIVES_DIR).toString())); // Add Native Path
|
||||
Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
||||
if (wrapper)
|
||||
|
@ -456,6 +515,15 @@ public static void main(String... args) throws Throwable {
|
|||
for (Path classpathURL : classPath) {
|
||||
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
|
||||
}
|
||||
for(ClientProfile.OptionalArgs optionalArgs : params.optionalClassPath)
|
||||
{
|
||||
if(!optionalArgs.mark) continue;
|
||||
LinkedList<Path> optionalClassPath = resolveClassPathList(params.clientDir, optionalArgs.args);
|
||||
for (Path classpathURL : optionalClassPath) {
|
||||
LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString());
|
||||
}
|
||||
}
|
||||
|
||||
URL[] classpathurls = resolveClassPath(params.clientDir, profile.getClassPath());
|
||||
classLoader = new PublicURLClassLoader(classpathurls, ClassLoader.getSystemClassLoader());
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
|
|
|
@ -143,6 +143,18 @@ public int hashCode() {
|
|||
return Objects.hash(file);
|
||||
}
|
||||
}
|
||||
public static class OptionalArgs
|
||||
{
|
||||
@LauncherAPI
|
||||
public boolean mark;
|
||||
@LauncherAPI
|
||||
public String[] args;
|
||||
|
||||
public OptionalArgs(String[] args, boolean mark) {
|
||||
this.mark = mark;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
// Updater and client watch service
|
||||
@LauncherAPI
|
||||
|
@ -170,6 +182,12 @@ public int hashCode() {
|
|||
private final List<String> clientArgs = new ArrayList<>();
|
||||
@LauncherAPI
|
||||
private final List<String> whitelist = new ArrayList<>();
|
||||
@LauncherAPI
|
||||
private final List<OptionalArgs> optionalJVMArgs = new ArrayList<>();
|
||||
@LauncherAPI
|
||||
private final List<OptionalArgs> optionalClientArgs = new ArrayList<>();
|
||||
@LauncherAPI
|
||||
private final List<OptionalArgs> optionalClassPath = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public int compareTo(ClientProfile o) {
|
||||
|
@ -191,6 +209,19 @@ public String[] getClassPath() {
|
|||
return classPath.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public List<OptionalArgs> getOptionalJVMArgs() {
|
||||
return optionalJVMArgs;
|
||||
}
|
||||
@LauncherAPI
|
||||
public List<OptionalArgs> getOptionalClientArgs() {
|
||||
return optionalClientArgs;
|
||||
}
|
||||
@LauncherAPI
|
||||
public List<OptionalArgs> getOptionalClassPath() {
|
||||
return optionalClassPath;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public String[] getClientArgs() {
|
||||
return clientArgs.toArray(new String[0]);
|
||||
|
|
Loading…
Reference in a new issue