mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-19 08:46:09 -04:00
add: support variables in prelaunch command which is supported by MultiMC. Closes #698
This commit is contained in:
parent
b957ca1931
commit
14cfd6abeb
@ -283,9 +283,18 @@ public class DefaultLauncher extends Launcher {
|
|||||||
|
|
||||||
File runDirectory = repository.getRunDirectory(version.getId());
|
File runDirectory = repository.getRunDirectory(version.getId());
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(options.getPreLaunchCommand()))
|
if (StringUtils.isNotBlank(options.getPreLaunchCommand())) {
|
||||||
new ProcessBuilder(options.getPreLaunchCommand())
|
String versionName = Optional.ofNullable(options.getVersionName()).orElse(version.getId());
|
||||||
|
String preLaunchCommand = options.getPreLaunchCommand()
|
||||||
|
.replace("$INST_NAME", versionName)
|
||||||
|
.replace("$INST_ID", versionName)
|
||||||
|
.replace("$INST_DIR", repository.getVersionRoot(version.getId()).getAbsolutePath())
|
||||||
|
.replace("$INST_MC_DIR", repository.getRunDirectory(version.getId()).getAbsolutePath())
|
||||||
|
.replace("$INST_JAVA", options.getJava().getBinary().toString());
|
||||||
|
|
||||||
|
new ProcessBuilder(preLaunchCommand)
|
||||||
.directory(runDirectory).start().waitFor();
|
.directory(runDirectory).start().waitFor();
|
||||||
|
}
|
||||||
|
|
||||||
Process process;
|
Process process;
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user