MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / parseTextParams

Method parseTextParams

daemon/src/entity/instance/instance.ts:535–563  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

533 }
534
535 public async parseTextParams(text: string) {
536 if (typeof text !== "string") return "";
537 text = text.replace(/\{mcsm_workspace\}/gim, this.absoluteCwdPath());
538 text = text.replace(/\{mcsm_cwd\}/gim, this.absoluteCwdPath());
539 text = text.replace(/\{mcsm_uuid\}/gim, this.instanceUuid);
540 text = text.replace(/\{mcsm_random\}/gim, randomUUID());
541 text = text.replace(/\{mcsm_run_as\}/gim, this.config.runAs);
542 text = text.replace(/\{mcsm_steamcmd\}/gim, STEAM_CMD_PATH);
543 text = text.replace(/\{mcsm_instance_id\}/gim, this.instanceUuid);
544 text = text.replace(/\{mcsm_instance_name\}/gim, this.config.nickname);
545 text = text.replace(/\{mcsm_instance_base_port\}/gim, String(this.config.basePort));
546
547 const javaId = this.config.java.id;
548 if (javaId) {
549 text = text.replace(/\{mcsm_java\}/gim, await javaManager.getJavaRuntimeCommand(javaId));
550 }
551
552 const ports = Array.from(
553 { length: globalConfiguration.config.portAssignInterval || 1 },
554 (_, index) => index + 1
555 );
556 const basePort = Number(this.config.basePort);
557 ports.forEach((portOffset) => {
558 const placeholder = `\\{mcsm_port${portOffset}\\}`;
559 const replacement = String(basePort + portOffset);
560 text = text.replace(new RegExp(placeholder, "gim"), replacement);
561 });
562 return text;
563 }
564
565 public getCrlfValue(): string {
566 return this.config.crlf === 2 ? "\r\n" : "\n";

Callers 4

onStartMethod · 0.80
onStartMethod · 0.80
createProcessMethod · 0.80
createProcessMethod · 0.80

Calls 2

absoluteCwdPathMethod · 0.95
getJavaRuntimeCommandMethod · 0.80

Tested by

no test coverage detected