Implemented ModMetadataReader for Fabric mods

This commit is contained in:
Kir_Antipov 2021-12-07 21:53:08 +03:00
parent a63e0b697d
commit 05a29057ca
2 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1,17 @@
import ModMetadata from "../../metadata/mod-metadata";
import ZippedModMetadataReader from "../../metadata/zipped-mod-metadata-reader";
import FabricModMetadata from "./fabric-mod-metadata";
export default class FabricModMetadataReader extends ZippedModMetadataReader {
constructor() {
super("fabric.mod.json");
}
protected loadConfig(buffer: Buffer): Record<string, unknown> {
return JSON.parse(buffer.toString("utf8"));
}
protected createMetadataFromConfig(config: Record<string, unknown>): ModMetadata {
return new FabricModMetadata(config);
}
}

View file

@ -1,9 +1,13 @@
import FabricModMetadataReader from "./fabric/fabric-mod-metadata-reader";
import ModLoaderType from "./mod-loader-type";
import ModMetadataReader from "./mod-metadata-reader";
export default class ModMetadataReaderFactory {
public create(loaderType: ModLoaderType): ModMetadataReader {
switch (loaderType) {
case ModLoaderType.Fabric:
return new FabricModMetadataReader();
default:
throw new Error(`Unknown mod loader "${ModLoaderType.toString(loaderType)}"`);
}