Skip to content

Commit 0acf2b0

Browse files
committed
fix: 修复-Xmx参数无法自动覆盖的问题&清理部分无效代码
1 parent 5d62e59 commit 0acf2b0

File tree

4 files changed

+6
-42
lines changed

4 files changed

+6
-42
lines changed

FCL/src/main/java/com/tungsten/fcl/game/FCLGameRepository.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public void globalizeVersionSetting(String id) {
335335
vs.setUsesGlobal(true);
336336
}
337337

338-
public LaunchOptions getLaunchOptions(String version, JavaVersion javaVersion, File gameDir, List<String> javaAgents) {
338+
public LaunchOptions getLaunchOptions(String version, JavaVersion javaVersion, File gameDir) {
339339
VersionSetting vs = getVersionSetting(version);
340340

341341
LaunchOptions.Builder builder = new LaunchOptions.Builder()
@@ -345,7 +345,7 @@ public LaunchOptions getLaunchOptions(String version, JavaVersion javaVersion, F
345345
.setVersionName(version)
346346
.setProfileName(FCLPath.CONTEXT.getString(R.string.app_name))
347347
.setGameArguments(StringUtils.tokenize(vs.getMinecraftArgs()))
348-
.setOverrideJavaArguments(StringUtils.tokenize(vs.getJavaArgs()))
348+
.setJavaArguments(StringUtils.tokenize(vs.getJavaArgs()))
349349
.setMaxMemory((int) (getAllocatedMemory(
350350
vs.getMaxMemory() * 1024L * 1024L,
351351
MemoryUtils.getFreeDeviceMemory(FCLPath.CONTEXT),
@@ -356,7 +356,6 @@ public LaunchOptions getLaunchOptions(String version, JavaVersion javaVersion, F
356356
.setWidth((int) (AndroidUtils.getScreenWidth(FCLApplication.getCurrentActivity()) * vs.getScaleFactor() / 100.0))
357357
.setHeight((int) (AndroidUtils.getScreenHeight(FCLApplication.getCurrentActivity()) * vs.getScaleFactor() / 100.0))
358358
.setServerIp(vs.getServerIp())
359-
.setJavaAgents(javaAgents)
360359
.setBEGesture(vs.isBeGesture())
361360
.setVkDriverSystem(vs.isVKDriverSystem())
362361
.setPojavBigCore(vs.isPojavBigCore())

FCL/src/main/java/com/tungsten/fcl/game/LauncherHelper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ private void launch0() {
135135
AtomicReference<Version> version = new AtomicReference<>(MaintainTask.maintain(repository, repository.getResolvedVersion(selectedVersion)));
136136
Optional<String> gameVersion = repository.getGameVersion(version.get());
137137
boolean integrityCheck = repository.unmarkVersionLaunchedAbnormally(selectedVersion);
138-
List<String> javaAgents = new ArrayList<>(0);
139138

140139
AtomicReference<JavaVersion> javaVersionRef = new AtomicReference<>();
141140

@@ -181,7 +180,7 @@ else if (configuration.getType().equals(ServerModpackProvider.INSTANCE.getName()
181180
.thenComposeAsync(() -> gameVersion.map(s -> new GameVerificationFixTask(dependencyManager, s, version.get())).orElse(null))
182181
.thenComposeAsync(() -> logIn(context, account).withStage("launch.state.logging_in"))
183182
.thenComposeAsync(authInfo -> Task.supplyAsync(() -> {
184-
LaunchOptions launchOptions = repository.getLaunchOptions(selectedVersion, javaVersionRef.get(), profile.getGameDir(), javaAgents);
183+
LaunchOptions launchOptions = repository.getLaunchOptions(selectedVersion, javaVersionRef.get(), profile.getGameDir());
185184
FCLGameLauncher launcher = new FCLGameLauncher(
186185
context,
187186
repository,

FCLCore/src/main/java/com/tungsten/fclcore/game/LaunchOptions.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ public class LaunchOptions implements Serializable {
3535
private String versionType;
3636
private String profileName;
3737
private final List<String> gameArguments = new ArrayList<>();
38-
private final List<String> overrideJavaArguments = new ArrayList<>();
3938
private final List<String> javaArguments = new ArrayList<>();
40-
private final List<String> javaAgents = new ArrayList<>(0);
4139
private Integer minMemory;
4240
private Integer maxMemory;
4341
private Integer width;
@@ -95,14 +93,6 @@ public List<String> getGameArguments() {
9593
return Collections.unmodifiableList(gameArguments);
9694
}
9795

98-
/**
99-
* The highest priority JVM arguments (overrides the version setting)
100-
*/
101-
@NotNull
102-
public List<String> getOverrideJavaArguments() {
103-
return Collections.unmodifiableList(overrideJavaArguments);
104-
}
105-
10696
/**
10797
* User custom additional java virtual machine command line arguments.
10898
*/
@@ -111,11 +101,6 @@ public List<String> getJavaArguments() {
111101
return Collections.unmodifiableList(javaArguments);
112102
}
113103

114-
@NotNull
115-
public List<String> getJavaAgents() {
116-
return Collections.unmodifiableList(javaAgents);
117-
}
118-
119104
/**
120105
* The minimum memory that the JVM can allocate.
121106
*/
@@ -238,24 +223,12 @@ public Builder setGameArguments(List<String> gameArguments) {
238223
return this;
239224
}
240225

241-
public Builder setOverrideJavaArguments(List<String> overrideJavaArguments) {
242-
options.overrideJavaArguments.clear();
243-
options.overrideJavaArguments.addAll(overrideJavaArguments);
244-
return this;
245-
}
246-
247226
public Builder setJavaArguments(List<String> javaArguments) {
248227
options.javaArguments.clear();
249228
options.javaArguments.addAll(javaArguments);
250229
return this;
251230
}
252231

253-
public Builder setJavaAgents(List<String> javaAgents) {
254-
options.javaAgents.clear();
255-
options.javaAgents.addAll(javaAgents);
256-
return this;
257-
}
258-
259232
public Builder setMinMemory(Integer minMemory) {
260233
options.minMemory = minMemory;
261234
return this;

FCLCore/src/main/java/com/tungsten/fclcore/launch/DefaultLauncher.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,15 @@ private CommandBuilder generateCommandLine() throws IOException {
8282

8383
getCacioJavaArgs(res, version, options);
8484

85-
res.addAllWithoutParsing(options.getOverrideJavaArguments().stream().filter(arg -> !arg.equals("noXmx")).collect(Collectors.toList()));
85+
res.addAllWithoutParsing(options.getJavaArguments().stream().filter(arg -> !arg.equals("noXmx")).collect(Collectors.toList()));
8686

87-
if (options.getMaxMemory() != null && options.getMaxMemory() > 0 && !options.getOverrideJavaArguments().contains("noXmx"))
88-
if (options.getOverrideJavaArguments().stream().noneMatch(arg -> arg.contains("-Xmx")))
89-
res.addDefault("-Xmx", options.getMaxMemory() + "m");
87+
if (options.getMaxMemory() != null && options.getMaxMemory() > 0)
88+
res.addDefault("-Xmx", options.getMaxMemory() + "m");
9089

9190
if (options.getMinMemory() != null && options.getMinMemory() > 0
9291
&& (options.getMaxMemory() == null || options.getMinMemory() <= options.getMaxMemory()))
9392
res.addDefault("-Xms", options.getMinMemory() + "m");
9493

95-
res.addAllDefaultWithoutParsing(options.getJavaArguments());
96-
9794
Charset encoding = OperatingSystem.NATIVE_CHARSET;
9895
String fileEncoding = res.addDefault("-Dfile.encoding=", encoding.name());
9996
if (fileEncoding != null && !"-Dfile.encoding=COMPAT".equals(fileEncoding)) {
@@ -235,10 +232,6 @@ private CommandBuilder generateCommandLine() throws IOException {
235232
if (argumentsFromAuthInfo != null && argumentsFromAuthInfo.getJvm() != null && !argumentsFromAuthInfo.getJvm().isEmpty())
236233
res.addAll(Arguments.parseArguments(argumentsFromAuthInfo.getJvm(), configuration));
237234

238-
for (String javaAgent : options.getJavaAgents()) {
239-
res.add("-javaagent:" + javaAgent);
240-
}
241-
242235
if (javaVersion.getVersion() != JavaVersion.JAVA_VERSION_8) {
243236
res.add("--add-exports");
244237
String pkg = version.getMainClass().substring(0, version.getMainClass().lastIndexOf("."));

0 commit comments

Comments
 (0)