Skip to content

Commit dd513fe

Browse files
Merge pull request #6 from OrnitheMC/fabric-launch-args
add required JVM args for Loader to profile json
2 parents ec6e34b + a36d96d commit dd513fe

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

src/main/java/net/ornithemc/meta/web/ProfileHandlerV3.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,16 @@ private static JsonNode buildProfileJson(int generation, LoaderInfoV3 info, Stri
167167
}
168168

169169
ObjectNode arguments = OrnitheMeta.MAPPER.createObjectNode();
170-
170+
ArrayNode jvmArgs = arguments.putArray("jvm");
171171
// I believe this is required to stop the launcher from complaining
172172
arguments.putArray("game");
173173

174+
if (generation >= 2) {
175+
// value not needed for FLoader, but QLoader requires the value to be true
176+
jvmArgs.add(info.getLoaderType().getJvmArguments().fixPackageAccess(true));
177+
}
178+
jvmArgs.add(info.getLoaderType().getJvmArguments().gameVersion(info.getGame(side)));
179+
174180
profile.set("arguments", arguments);
175181

176182
profile.put("libraries", libraries);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2019 FabricMC
3+
*
4+
* Modifications copyright (c) 2022 OrnitheMC
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package net.ornithemc.meta.web.models;
20+
21+
public class JvmArguments {
22+
23+
String fixPackageAccess;
24+
String gameVersion;
25+
26+
public JvmArguments(String fixPackageAccess, String gameVersion) {
27+
this.fixPackageAccess = fixPackageAccess;
28+
this.gameVersion = gameVersion;
29+
}
30+
31+
public String fixPackageAccess(boolean value) {
32+
return this.fixPackageAccess + "=" + value;
33+
}
34+
35+
public String gameVersion(String value) {
36+
return this.gameVersion + "=" + value;
37+
}
38+
}

src/main/java/net/ornithemc/meta/web/models/LoaderType.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,22 @@
2222

2323
public enum LoaderType {
2424

25-
FABRIC("fabric", VersionDatabase.FABRIC_MAVEN_URL),
26-
QUILT("quilt", VersionDatabase.QUILT_MAVEN_URL),
25+
FABRIC("fabric", VersionDatabase.FABRIC_MAVEN_URL, new JvmArguments("-Dfabric.fixPackageAccess", "-Dfabric.gameVersion")),
26+
QUILT("quilt", VersionDatabase.QUILT_MAVEN_URL, new JvmArguments("-Dloader.fixPackageAccess", "-Dloader.gameVersion")),
2727
ORNITHE("ornithe", VersionDatabase.ORNITHE_MAVEN_URL);
2828

2929
private final String name;
3030
private final String maven;
31+
private final JvmArguments jvmArguments;
3132

3233
private LoaderType(String name, String maven) {
34+
this(name, maven, new JvmArguments(null, null));
35+
}
36+
37+
private LoaderType(String name, String maven, JvmArguments jvmArguments) {
3338
this.name = name;
3439
this.maven = maven;
40+
this.jvmArguments = jvmArguments;
3541
}
3642

3743
public String getName() {
@@ -41,4 +47,8 @@ public String getName() {
4147
public String getMavenUrl() {
4248
return maven;
4349
}
50+
51+
public JvmArguments getJvmArguments() {
52+
return jvmArguments;
53+
}
4454
}

0 commit comments

Comments
 (0)