diff --git a/src/metadata/fabric/fabric-mod-metadata-reader.ts b/src/metadata/fabric/fabric-mod-metadata-reader.ts new file mode 100644 index 0000000..fbe4a6a --- /dev/null +++ b/src/metadata/fabric/fabric-mod-metadata-reader.ts @@ -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 { + return JSON.parse(buffer.toString("utf8")); + } + + protected createMetadataFromConfig(config: Record): ModMetadata { + return new FabricModMetadata(config); + } +} diff --git a/src/metadata/mod-metadata-reader-factory.ts b/src/metadata/mod-metadata-reader-factory.ts index 3abf394..0c8dfe8 100644 --- a/src/metadata/mod-metadata-reader-factory.ts +++ b/src/metadata/mod-metadata-reader-factory.ts @@ -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)}"`); }