Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lzimul/minecraft-mod-updater
A Minecraft mod update tool based on Node.JS
https://github.com/lzimul/minecraft-mod-updater
Last synced: 5 days ago
JSON representation
A Minecraft mod update tool based on Node.JS
- Host: GitHub
- URL: https://github.com/lzimul/minecraft-mod-updater
- Owner: lZiMUl
- License: gpl-3.0
- Created: 2023-12-06T15:40:50.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-15T23:23:54.000Z (7 months ago)
- Last Synced: 2024-10-30T07:21:58.179Z (3 months ago)
- Language: TypeScript
- Homepage: https://lzimul.top
- Size: 1.24 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Minecraft Mod Updater
### A Minecraft mod update tool based on Node.js
# Use it directly
## Installation
### Using npm
```bash
npm install -g minecraft-mod-updater
```
## Command
### CLI (Command aliases)
```bash
minecraft-mod-updater-cli
mcmu-cli
mcmuc
```
### GUI (Command aliases)
```bash
minecraft-mod-updater-gui
mcmu-gui
mcmug
```
## Example
### CLI (Parameters are optional)
```bash
mcmuc -h
mcmuc -t Manifest -i "./MyModPack/manifest.json" -o "./MyModPack" -k "xxxxxxxxxxxxxxxxxxxxxx" -f
mcmuc -t JarFile -i "./MyModPack/mods" -o "./MyModPack" -v 1.20.1 -l forge -k "xxxxxxxxxxxxxxxxxxxxxx" -f
```
### GUI (Parameters are optional)
```bash
mcmug -h
mcmuc -t Manifest -i "./MyModPack/manifest.json" -o "./MyModPack" -k "xxxxxxxxxxxxxxxxxxxxxx" -f
mcmuc -t JarFile -i "./MyModPack/mods" -o "./MyModPack" -v 1.20.1 -l forge -k "xxxxxxxxxxxxxxxxxxxxxx" -f
````
## Parameter (General parameters)
```text
-t, --type read type is jarFile or manifest
-i, --input path to the input
-o, --output path to the output
-v, --version game version
-l, --loader mod loader platform
-k, --apiKey api key
-f, --forceDownload force download
-h, --help display help for command
```
# Secondary development
### If you need to do secondary development, use the following command:
## Installation
### Using npm
```bash
npm install --save minecraft-mod-updater
```
## Example```ts
import {
ModJarFileUpdater,
ModManifestUpdater,
type ModInfo,
type ModUpdateStatus,
ErrorEnum,
type ErrorType,
type Parameter
} from 'minecraft-mod-updater';
import {blueBright, greenBright, magentaBright, redBright, yellowBright} from 'chalk';// Manifest Mode
function manifest(input: string, forceDownload: boolean): void {
if (existsSync(input)) {
const modUpdater: ModManifestUpdater = new ModManifestUpdater(input, {
output,
apiKey,
forceDownload
});
modUpdater.addEventListener(EventEnum.DOWNLOADING, (mod: ModInfo): void => info(`${magentaBright('Downloading:')} ${blueBright(mod.fileName)} {(${yellowBright(mod.modId)}) [${redBright(mod.fileID)} => ${greenBright(mod.id)}]} -> ${blueBright(mod.downloadUrl)}`));
modUpdater.addEventListener(EventEnum.DOWNLOADED, (mod: ModInfo): void => info(`${greenBright('The download is complete')}: ${blueBright(mod.fileName)}\n`));
modUpdater.addEventListener(EventEnum.SKIPPED, (mod: ModInfo): void => warn(`${greenBright('Already the latest version, the update has been skipped')}: ${blueBright(mod.fileName)} (${yellowBright(mod.modId)} [${greenBright(mod.fileID)} == ${greenBright(mod.id)}]) \n`));
modUpdater.addEventListener(EventEnum.FINISHED, (mod: ModUpdateStatus): void => info(mod, '\n', greenBright('The update is complete')));
modUpdater.addEventListener>(EventEnum.ERRORED, ({ type, mod }: ErrorType): void => {
switch (type) {
case ErrorEnum.ADDRESS:
error(`${redBright('=====Error: Unable to get file address, please download it manually=====')}\nMod ID: ${yellowBright(mod.modId)}\nThe name of the mod file: ${magentaBright(mod.fileName)}\n`);
break;
case ErrorEnum.DOWNLOAD:
error(`${redBright('=====Error: Unable to download the file, please download it manually=====')}\nMod ID: ${yellowBright(mod.modId)}\nThe name of the mod file: ${magentaBright(mod.fileName)}\n`);
break;
}
});
} else {
error(redBright('The manifest.json file does not exist, please create it and try again alive to view the help with mcmu -h'));
}
}// JarFile Mode
function jarFile(input: string): void {
const dirPath: string = input.includes('json') ? resolve('./mods'): input;
if (existsSync(dirPath)) {
if (!version) {
error(redBright('The version is not specified, please specify it and try again alive to view the help with mcmu -h'));
return;
}
if (!loader) {
error(redBright('The modLoader is not specified, please specify it and try again alive to view the help with mcmu -h'));
return;
}
ModJarFileUpdater.fakeModManifestFile.minecraft.version = version;
ModJarFileUpdater.fakeModManifestFile.minecraft.modLoaders.push({
'id': loader,
'primary': true
});
const modJarFileUpdater: ModJarFileUpdater = new ModJarFileUpdater(dirPath);
modJarFileUpdater.addEventListener(EventNameEnum.INIT, (mod: ModInfo): void => info(`${magentaBright('Init:')} ${blueBright(mod.fileName)} (${yellowBright(mod.modId)})`));
modJarFileUpdater.addEventListener(EventNameEnum.FINISHED, (): void => {
manifest(join(resolve('.'), './temp.json'), true);
});
} else {
error(redBright('The mods dir does not exist, please create it and try again alive to view the help with mcmu -h'));
}
}switch (type) {
case 'Manifest':
manifest(input, forceDownload);
break;
case 'JarFile':
jarFile(input);
break;
default:
error(redBright('The read type is incorrect, please try again alive to view the help with mcmu -h'));
}```