mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-22 00:11:02 -05:00
Implemented ModMetadataReader for Forge mods
This commit is contained in:
parent
ddc460484e
commit
cb76b6f43f
4 changed files with 29 additions and 1 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -4828,6 +4828,11 @@
|
|||
"is-number": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"toml": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz",
|
||||
"integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w=="
|
||||
},
|
||||
"tough-cookie": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz",
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
"fast-glob": "^3.2.7",
|
||||
"formdata-node": "^4.2.4",
|
||||
"node-fetch": "^3.0.0",
|
||||
"node-stream-zip": "^1.15.0"
|
||||
"node-stream-zip": "^1.15.0",
|
||||
"toml": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
|
18
src/metadata/forge/forge-mod-metadata-reader.ts
Normal file
18
src/metadata/forge/forge-mod-metadata-reader.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import ModMetadata from "../../metadata/mod-metadata";
|
||||
import toml from "toml";
|
||||
import ZippedModMetadataReader from "../../metadata/zipped-mod-metadata-reader";
|
||||
import ForgeModMetadata from "./forge-mod-metadata";
|
||||
|
||||
export default class ForgeModMetadataReader extends ZippedModMetadataReader {
|
||||
constructor() {
|
||||
super("META-INF/mods.toml");
|
||||
}
|
||||
|
||||
protected loadConfig(buffer: Buffer): Record<string, unknown> {
|
||||
return toml.parse(buffer.toString("utf8"));
|
||||
}
|
||||
|
||||
protected createMetadataFromConfig(config: Record<string, unknown>): ModMetadata {
|
||||
return new ForgeModMetadata(config);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import FabricModMetadataReader from "./fabric/fabric-mod-metadata-reader";
|
||||
import ForgeModMetadataReader from "./forge/forge-mod-metadata-reader";
|
||||
import ModLoaderType from "./mod-loader-type";
|
||||
import ModMetadataReader from "./mod-metadata-reader";
|
||||
|
||||
|
@ -8,6 +9,9 @@ export default class ModMetadataReaderFactory {
|
|||
case ModLoaderType.Fabric:
|
||||
return new FabricModMetadataReader();
|
||||
|
||||
case ModLoaderType.Forge:
|
||||
return new ForgeModMetadataReader();
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown mod loader "${ModLoaderType.toString(loaderType)}"`);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue