diff --git a/README.md b/README.md index a53cf0d..84ce423 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,11 @@ Before you can execute this phase, you need a `modpack.json` file with contents "type": "maven", "artifact": "org.cyclops.commoncapabilities:CommonCapabilities:1.12.2-2.4.4-309", "repo": "https://oss.jfrog.org/artifactory/simple/libs-release/" + }, + { + "type": "raw", + "name": "integratedscripting-1.19.2-1.0.0-61.jar", + "url": "https://www.dropbox.com/s/mbbikni5ieyttuq/integratedscripting-1.19.2-1.0.0-61.jar?dl=1" } ] } diff --git a/lib/modloader/ModLoader.ts b/lib/modloader/ModLoader.ts index f3fac3c..71935b1 100644 --- a/lib/modloader/ModLoader.ts +++ b/lib/modloader/ModLoader.ts @@ -99,25 +99,32 @@ export class ModLoader { process.stdout.write(` - ${fileName} from CurseForge...\n`); const url = `https://minecraft.curseforge.com/api/maven/${mod.project}/${mod.artifact .replace(/-/g, '/')}/${fileName}`; - const response = await fetch(url); - if (response.status !== 200) { - throw new Error(response.statusText + ' on ' + url); - } - await new Promise((resolve, reject) => { - response.body - .on('error', reject) - .on('end', resolve) - .pipe(fs.createWriteStream(join(modsDir, fileName))); - }); + await this.downloadFile(url, fileName, modsDir); } else if (mod.type === 'maven') { process.stdout.write(` - ${mod.artifact} from ${mod.repo}...\n`); await download(mod.artifact, modsDir, mod.repo); + } else if (mod.type === 'raw') { + process.stdout.write(` - ${mod.name} from ${mod.url}...\n`); + await this.downloadFile(mod.url, mod.name, modsDir); } else { throw new Error('Unknown mod type ' + ( mod).type); } } } + public async downloadFile(url: string, fileName: string, modsDir: string): Promise { + const response = await fetch(url); + if (response.status !== 200) { + throw new Error(response.statusText + ' on ' + url); + } + await new Promise((resolve, reject) => { + response.body + .on('error', reject) + .on('end', resolve) + .pipe(fs.createWriteStream(join(modsDir, fileName))); + }); + } + /** * Start the server and execute a command to dump all registries */ @@ -141,7 +148,7 @@ export class ModLoader { // Once the loading is complete, send our command and stop the server proc.stdout.on('data', (line: string) => { - if (line.indexOf('[Server thread/INFO]: Done') >= 0) { + if (line.indexOf('Done') >= 0 && line.indexOf('For help, type "help"') >= 0) { process.stdout.write('Dumping registries...\n'); this.sendCommand(proc, '/cyclopscore dumpregistries'); this.sendCommand(proc, '/stop'); @@ -312,7 +319,7 @@ export interface IModLoaderArgs { versionMinecraft: string; } -export type IMod = IModMaven | IModCurseforge; +export type IMod = IModMaven | IModCurseforge | IModRaw; export interface IModMaven { type: 'maven'; @@ -326,3 +333,9 @@ export interface IModCurseforge { artifact: string; version: string; } + +export interface IModRaw { + type: 'raw'; + name: string; + url: string; +}