mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-22 08:20:58 -05:00
Implemented ModMetadataReader for Fabric mods
This commit is contained in:
parent
a63e0b697d
commit
05a29057ca
2 changed files with 21 additions and 0 deletions
17
src/metadata/fabric/fabric-mod-metadata-reader.ts
Normal file
17
src/metadata/fabric/fabric-mod-metadata-reader.ts
Normal 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);
|
||||
}
|
||||
}
|
|
@ -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)}"`);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue