Repository: HMCL-dev/HMCL (language: java)

Issue:
[Bug] 高级设置中的包装器会被添加两次
### 平台 | Platform

Windows 11

### 问题描述 | Problem Description

1. 在版本特定/全局高级设置中设置包装器
2. 在主界面启动游戏

### 启动器崩溃报告 / 启动器日志文件 | Launcher Crash Report / Launcher Log File

[hmcl-exported-logs-2024-03-15T15-02-15.log](https://github.com/HMCL-dev/HMCL/files/14620254/hmcl-exported-logs-2024-03-15T15-02-15.log)



Discussion / hints:
这里使用的wrapper可以看作是一个会无条件返回-1的程序
在这两行里各添加了一次wrapper
https://github.com/HMCL-dev/HMCL/blob/b88d7c4fd224ee5c37205970d49d0aa66c1b2738/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java#L105
https://github.com/HMCL-dev/HMCL/blob/b88d7c4fd224ee5c37205970d49d0aa66c1b2738/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java#L433

Fix patch:
diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java
index 4bf3bf2d34..2375d762aa 100644
--- a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java
+++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java
@@ -102,7 +102,7 @@ private Command generateCommandLine(File nativeFolder) throws IOException {
 
         // Executable
         if (StringUtils.isNotBlank(options.getWrapper()))
-            res.addAllWithoutParsing(StringUtils.tokenize(options.getWrapper()));
+            res.addAllWithoutParsing(StringUtils.tokenize(options.getWrapper(), getEnvVars()));
 
         res.add(options.getJava().getBinary().toString());
 
@@ -429,9 +429,6 @@ public ManagedProcess launch() throws IOException, InterruptedException {
 
         // To guarantee that when failed to generate launch command line, we will not call pre-launch command
         List<String> rawCommandLine = command.commandLine.asList();
-        if (StringUtils.isNotBlank(options.getWrapper())) {
-            rawCommandLine.addAll(0, StringUtils.tokenize(options.getWrapper(), getEnvVars()));
-        }
 
         if (command.tempNativeFolder != null) {
             Files.deleteIfExists(command.tempNativeFolder);


Test patch: