diff --git a/locales/version b/locales/version index bfc72a0..110ab5a 100644 --- a/locales/version +++ b/locales/version @@ -1 +1 @@ -4.0.0-alpha.6 \ No newline at end of file +4.0.0-alpha.7 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 637183c..a783ae6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dmclc", - "version": "4.0.0-alpha.6", + "version": "4.0.0-alpha.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "dmclc", - "version": "4.0.0-alpha.6", + "version": "4.0.0-alpha.7", "license": "MIT", "dependencies": { "@types/marked": "^4.0.8", diff --git a/package.json b/package.json index 04fcf30..93b3ebf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dmclc", - "version": "4.0.0-alpha.6", + "version": "4.0.0-alpha.7", "description": "Dolphin Minecraft Launcher Core", "typings": "./lib/index.d.ts", "module": "./lib/index.js", diff --git a/src/auth/account.ts b/src/auth/account.ts index a1813cb..d93bcb9 100644 --- a/src/auth/account.ts +++ b/src/auth/account.ts @@ -21,7 +21,7 @@ export interface Account { /** * Prepare for launch. For example, download your Java Agent. */ - prepareLaunch(): Promise + prepareLaunch(versionDir: string): Promise /** * Get extra JVM arguments. For example, Java Agent. */ diff --git a/src/auth/ali_account.ts b/src/auth/ali_account.ts index af10231..b967507 100644 --- a/src/auth/ali_account.ts +++ b/src/auth/ali_account.ts @@ -20,10 +20,10 @@ export class AuthlibInjectorAccount extends YggdrasilAccount return await super.login(); } - async prepareLaunch(): Promise { + async prepareLaunch(versionDir: string): Promise { const obj = await got("https://bmclapi2.bangbang93.com/mirrors/authlib-injector/artifact/latest.json").json(); const sha256 = obj.checksums.sha256; - const path = `${this.root.toString()}/authlib-injector-latest.jar`; + const path = `${versionDir}/authlib-injector-latest.jar`; if (!fs.existsSync(path) || !checkFile(path, sha256, "sha256")) { return await download(obj.download_url, path, this.launcher); } diff --git a/src/auth/mul_account.ts b/src/auth/mul_account.ts index 28488be..caa5186 100644 --- a/src/auth/mul_account.ts +++ b/src/auth/mul_account.ts @@ -18,15 +18,15 @@ export class MinecraftUniversalLoginAccount extends YggdrasilAccount { - const path = `${this.root}/nide8auth.jar`; + async prepareLaunch(versionDir: string): Promise { + const path = `${versionDir}/nide8auth.jar`; if (!fs.existsSync(path)) { return await download("https://login.mc-user.com:233/index/jar", path, this.launcher); } return true; } - async getLaunchJVMArgs (): Promise { + async getLaunchJVMArgs(): Promise { return [`-javaagent:./nide8auth.jar=${this.data.serverID}`, "-Dnide8auth.client=true"]; } toString (): string { diff --git a/src/auth/yggdrasil/yggdrasil_account.ts b/src/auth/yggdrasil/yggdrasil_account.ts index 8b876eb..35c30a5 100644 --- a/src/auth/yggdrasil/yggdrasil_account.ts +++ b/src/auth/yggdrasil/yggdrasil_account.ts @@ -14,7 +14,7 @@ export abstract class YggdrasilAccount implements A this.root = launcher.rootPath; } - abstract prepareLaunch(): Promise; + abstract prepareLaunch(versionDir: string): Promise; abstract getLaunchJVMArgs(mc: MinecraftVersion): Promise; async getLaunchGameArgs(): Promise> { const map: Map = new Map(); diff --git a/src/launcher.ts b/src/launcher.ts index 5390bfc..227bd08 100644 --- a/src/launcher.ts +++ b/src/launcher.ts @@ -63,7 +63,7 @@ export class Launcher { specialNatives: Record; }; private realRootPath = ""; - version = "4.0.0-alpha.6"; + static readonly version = "4.0.0-alpha.7"; /** * Create a new Launcher object. * @throws {@link FormattedError} diff --git a/src/mods/manage/ModManager.ts b/src/mods/manage/ModManager.ts index 485a660..7e55c21 100644 --- a/src/mods/manage/ModManager.ts +++ b/src/mods/manage/ModManager.ts @@ -13,7 +13,8 @@ export class ModManager { async saveInfo(): Promise {} - async findMods(moddir: string): Promise { + async findMods(): Promise { + const moddir = `${this.version.versionLaunchWorkDir}/mods`; const val: ModJarInfo[] = []; for (const mod of await fsPromises.readdir(moddir)) { const modJar = `${moddir}/${mod}`; @@ -33,7 +34,7 @@ export class ModManager { let moddir = `${this.version.versionLaunchWorkDir}/mods`; if (!fs.existsSync(moddir) && fs.statSync(moddir).isDirectory()) return []; const loader = this.launcher.loaders.get(this.version.extras.loaders[0].name); - return loader?.checkMods((await this.findMods(moddir)).map(v=>v.manifests).flat(), this.version.extras.version, this.version.extras.loaders[0].version) ?? []; + return loader?.checkMods((await this.findMods()).map(v=>v.manifests).flat(), this.version.extras.version, this.version.extras.loaders[0].version) ?? []; } async searchMod(name: string, skip: number, limit: number): Promise { diff --git a/src/version.ts b/src/version.ts index f0285f6..10b4162 100644 --- a/src/version.ts +++ b/src/version.ts @@ -127,7 +127,7 @@ export class MinecraftVersion { * @returns The Minecraft process. Both stdout and stderr uses UTF-8. */ async run(account: Account): Promise { - await account.prepareLaunch(); + await account.prepareLaunch(this.versionLaunchWorkDir); await this.completeVersionInstall(); await this.extractNative(this.versionObject, this.name); const args = await this.getArguments(this.versionObject, account);