131 lines
4.3 KiB
Plaintext
131 lines
4.3 KiB
Plaintext
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: "mccomm2023",
|
|
icon: "https://storage.ragestudio.net/gose-uploads/mccom/MCx128.png",
|
|
pack_name: "MCCommunity",
|
|
version: "1.1.0",
|
|
init: ({ pack_dir, tmp_dir }) => {
|
|
return {
|
|
git_update: [
|
|
{
|
|
path: pack_dir,
|
|
branch: "main",
|
|
url: "https://git.ragestudio.net/srgooglo/pack_mcommunity_2023"
|
|
}
|
|
],
|
|
git_clones_steps: [
|
|
{
|
|
path: pack_dir,
|
|
branch: "main",
|
|
url: "https://git.ragestudio.net/srgooglo/pack_mcommunity_2023"
|
|
}
|
|
],
|
|
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://storage.ragestudio.net/gose-uploads/mccom/MCx128.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))
|
|
}
|
|
},
|
|
} |