commit a12da2bca1343f8e3a7a4a8401cb99369f74fc95 Author: Cubyto Date: Mon Oct 30 20:33:27 2023 +0100 added manifest diff --git a/manifest b/manifest new file mode 100644 index 0000000..7330ac9 --- /dev/null +++ b/manifest @@ -0,0 +1,131 @@ +const os = require("node:os") +const path = require("node:path") +const fs = require("node:fs") +const child_process = require("node:child_process") + +function resolveMcPath() { + let minecraftGameFolder + + switch (os.type()) { + case "Darwin": + minecraftGameFolder = path.join( + os.homedir(), + "/Library", + "Application Support", + "minecraft" + ) + break + + case "win32": + case "Windows_NT": + minecraftGameFolder = path.join( + process.env.APPDATA || + path.join(os.homedir(), "AppData", "Roaming"), + ".minecraft" + ) + + break + default: + minecraftGameFolder = path.join(os.homedir(), ".minecraft"); + break + } + + return minecraftGameFolder +} + +module.exports = { + id: "cubyworld", + icon: "https://art.ngfiles.com/images/2469000/2469308_ricketyhalo_pepsi-can-i-made.png", + pack_name: "CubyWorld", + version: "1.0.0", + init: ({ pack_dir, tmp_dir }) => { + return { + git_update: [ + { + path: pack_dir, + branch: "main", + url: "https://git.ragestudio.net/cubyto/cubyworld" + } + ], + git_clones_steps: [ + { + path: pack_dir, + branch: "main", + url: "https://git.ragestudio.net/cubyto/cubyworld" + } + ], + http_downloads: [ + { + path: `${pack_dir}/tmp/forge-installer.jar`, + url: "https://storage.ragestudio.net/gose-uploads/mccom/forge-1.20.1-47.2.0-installer.jar", + }, + { + path: `${pack_dir}/icon/mc.png`, + url: "https://art.ngfiles.com/images/2469000/2469308_ricketyhalo_pepsi-can-i-made.png", + } + ] + } + }, + after_install: async ({ manifest, pack_dir, tmp_dir, spinner }) => { + if (spinner) { + spinner.color = "yellow" + spinner.text = `Installing Forge version and libraries...` + } + + await new Promise((resolve, reject) => { + const process = child_process.execFile("java", ["-jar", `${pack_dir}/tmp/forge-installer.jar`, "-installClient"], { + cwd: pack_dir, + shell: true, + }) + + process.on("exit", resolve) + process.on("error", reject) + }) + + if (spinner) { + spinner.succeed() + } + + const minecraftGameFolder = resolveMcPath() + + const profilesFilePath = path.join(minecraftGameFolder, "launcher_profiles.json") + + if (fs.existsSync(profilesFilePath)) { + let launcherJSON = fs.readFileSync(profilesFilePath, "utf8") + + launcherJSON = JSON.parse(launcherJSON) + + launcherJSON.profiles[manifest.id] = { + name: manifest.pack_name, + gameDir: pack_dir, + created: "2023-00-00T00:00:00.002Z", + javaArgs: "-Xmx4G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M", + lastVersionId: "1.20.1-forge-47.2.0", + version: "1.20.1-forge-47.2.0", + type: "custom", + path: `${pack_dir}/icon/mc.png`, + } + + fs.writeFileSync(profilesFilePath, JSON.stringify(launcherJSON, null, 2)) + } else { + console.warn("WARNING: Its seems that you are not using the official launcher launcher, you must create a new profile on your launcher!") + console.log(`Installation Path: ${pack_dir}`) + console.log(`Version: 1.20.1-forge-47.2.0`) + } + }, + uninstall: async ({ manifest, pack_dir, tmp_dir, spinner }) => { + const minecraftGameFolder = resolveMcPath() + + const profilesFilePath = path.join(minecraftGameFolder, "launcher_profiles.json") + + if (fs.existsSync(profilesFilePath)) { + let launcherJSON = fs.readFileSync(profilesFilePath, "utf8") + + launcherJSON = JSON.parse(launcherJSON) + + delete launcherJSON.profiles[manifest.id] + + fs.writeFileSync(profilesFilePath, JSON.stringify(launcherJSON, null, 2)) + } + }, +} \ No newline at end of file