feat: allow to specify custom game args
This commit is contained in:
parent
2819f164bc
commit
5cbf88c6a2
2 changed files with 26 additions and 9 deletions
|
|
@ -93,10 +93,11 @@ export async function generateLaunchArguments(
|
|||
gameRoot: string,
|
||||
versionJar: string,
|
||||
auth: Auth,
|
||||
options = {
|
||||
minRam: "2G",
|
||||
maxRam: "2G",
|
||||
customJvm: "",
|
||||
options: {
|
||||
minRam?: string;
|
||||
maxRam?: string;
|
||||
customJvmArgs?: string;
|
||||
customGameArgs?: string;
|
||||
},
|
||||
) {
|
||||
// Log4j /!\
|
||||
|
|
@ -122,20 +123,26 @@ export async function generateLaunchArguments(
|
|||
p(game, arg);
|
||||
}
|
||||
|
||||
if (options.customJvm !== "") {
|
||||
for (const arg of options.customJvm.split(" ")) {
|
||||
if (options.customJvmArgs !== "") {
|
||||
for (const arg of options.customJvmArgs.split(" ")) {
|
||||
jvm.push(arg);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.customGameArgs !== "") {
|
||||
for (const arg of options.customGameArgs.split(" ")) {
|
||||
game.push(arg);
|
||||
}
|
||||
}
|
||||
|
||||
const log4j = await getArgument(versionManifest, gameRoot);
|
||||
|
||||
return {
|
||||
command: getJavaExecutable(javaRoot),
|
||||
args: [
|
||||
...jvm,
|
||||
`-Xms${options.minRam}`,
|
||||
`-Xmx${options.maxRam}`,
|
||||
`-Xms${options.minRam || "2G"}`,
|
||||
`-Xmx${options.maxRam || "2G"}`,
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:+UseG1GC",
|
||||
"-XX:G1NewSizePercent=20",
|
||||
|
|
|
|||
|
|
@ -41,9 +41,13 @@ export class Instance {
|
|||
modLoader: { name: string; version: string };
|
||||
auth: Auth;
|
||||
paths: Paths;
|
||||
|
||||
args: { java: string; game: string };
|
||||
versionManifest: Version;
|
||||
|
||||
constructor() {
|
||||
this.args = { java: "", game: "" };
|
||||
}
|
||||
|
||||
setVersion(version: string) {
|
||||
this.version = version;
|
||||
}
|
||||
|
|
@ -80,6 +84,11 @@ export class Instance {
|
|||
this.auth = auth;
|
||||
}
|
||||
|
||||
setArgs({ java, game }: { java?: string; game?: string }) {
|
||||
this.args.java = java || "";
|
||||
this.args.game = game || "";
|
||||
}
|
||||
|
||||
async install() {
|
||||
this.versionManifest = await core.version.getVersionManifest(
|
||||
this.version,
|
||||
|
|
@ -140,6 +149,7 @@ export class Instance {
|
|||
path.join(this.paths.root),
|
||||
path.join(this.paths.root, `${this.version}.jar`),
|
||||
this.auth,
|
||||
{ customGameArgs: this.args.game, customJvmArgs: this.args.java },
|
||||
);
|
||||
|
||||
const process = core.launch(args, this.paths.root);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue