[FEATURE] LauncherGuard module

This commit is contained in:
Gravita 2023-04-11 13:28:31 +07:00
parent 06e9bc8578
commit 95da394a5d
2 changed files with 19 additions and 1 deletions

View file

@ -31,6 +31,8 @@
import java.util.stream.Collectors;
public class ClientLauncherProcess {
public final List<String> pre = new LinkedList<>();
public final ClientParams params = new ClientParams();
public final List<String> jvmArgs = new LinkedList<>();
public final List<String> jvmModules = new LinkedList<>();
@ -134,7 +136,7 @@ private void applyClientProfile() {
public void start(boolean pipeOutput) throws IOException, InterruptedException {
if (isStarted) throw new IllegalStateException("Process already started");
LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderPreLaunchEvent(this));
List<String> processArgs = new LinkedList<>();
List<String> processArgs = new LinkedList<>(pre);
processArgs.add(executeFile.toString());
processArgs.addAll(jvmArgs);
if (javaVersion.version >= 9) {

View file

@ -112,6 +112,22 @@ public static Path getGuardDir() {
return dir.resolve("guard");
}
public static Path getGuardDir(JVMHelper.ARCH arch, JVMHelper.OS os) {
Path dir = getGuardDir().resolve(makeSpecialGuardDirName(arch, os));
try {
IOHelper.createParentDirs(dir);
} catch (Throwable e) {
throw new RuntimeException(e);
}
return dir;
}
public static String makeSpecialGuardDirName(JVMHelper.ARCH arch, JVMHelper.OS os) {
return String.format("%s-%s", arch.name, os.name);
}
public static Path getLegacyLauncherDir(String projectname) {
return IOHelper.HOME_DIR.resolve(projectname);
}