Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/net/ornithemc/meta/web/ProfileHandlerV3.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,16 @@ private static JsonNode buildProfileJson(int generation, LoaderInfoV3 info, Stri
}

ObjectNode arguments = OrnitheMeta.MAPPER.createObjectNode();

ArrayNode jvmArgs = arguments.putArray("jvm");
// I believe this is required to stop the launcher from complaining
arguments.putArray("game");

if (generation >= 2) {
// value not needed for FLoader, but QLoader requires the value to be true
jvmArgs.add(info.getLoaderType().getJvmArguments().fixPackageAccess(true));
}
jvmArgs.add(info.getLoaderType().getJvmArguments().gameVersion(info.getGame(side)));

profile.set("arguments", arguments);

profile.put("libraries", libraries);
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/net/ornithemc/meta/web/models/JvmArguments.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2019 FabricMC
*
* Modifications copyright (c) 2022 OrnitheMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.ornithemc.meta.web.models;

public class JvmArguments {

String fixPackageAccess;
String gameVersion;

public JvmArguments(String fixPackageAccess, String gameVersion) {
this.fixPackageAccess = fixPackageAccess;
this.gameVersion = gameVersion;
}

public String fixPackageAccess(boolean value) {
return this.fixPackageAccess + "=" + value;
}

public String gameVersion(String value) {
return this.gameVersion + "=" + value;
}
}
14 changes: 12 additions & 2 deletions src/main/java/net/ornithemc/meta/web/models/LoaderType.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,22 @@

public enum LoaderType {

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

private final String name;
private final String maven;
private final JvmArguments jvmArguments;

private LoaderType(String name, String maven) {
this(name, maven, new JvmArguments(null, null));
}

private LoaderType(String name, String maven, JvmArguments jvmArguments) {
this.name = name;
this.maven = maven;
this.jvmArguments = jvmArguments;
}

public String getName() {
Expand All @@ -41,4 +47,8 @@ public String getName() {
public String getMavenUrl() {
return maven;
}

public JvmArguments getJvmArguments() {
return jvmArguments;
}
}