UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

41 lines (39 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateSkinPackJson = void 0; exports.getLocKeysFromSkinPack = getLocKeysFromSkinPack; const SchemaValidation_1 = require("../../jsonschema/SchemaValidation"); /* Schema for validating SkinPack */ const SkinPackSchema = { type: "object", properties: { localization_name: { type: "string" }, serialize_name: { type: "string" }, skins: { type: "array", items: { type: "object", properties: { localization_name: { type: "string" }, geometry: { type: "string" }, texture: { type: "string" }, type: { type: "string" }, }, required: ["localization_name", "geometry", "texture", "type"], }, }, }, required: ["localization_name", "serialize_name", "skins"], }; /* validates json against SkinPack-Schema and returns it as a fully typed SkinPack object alias of validateJsonAndAssert for clarity and convenience */ const validateSkinPackJson = (json) => (0, SchemaValidation_1.validateJsonAndAssert)(json, SkinPackSchema); exports.validateSkinPackJson = validateSkinPackJson; function getLocKeysFromSkinPack(pack) { const skinKeys = pack.skins.map((skin) => `skin.${pack.localization_name}.${skin.localization_name}`); return [`skinpack.${pack.localization_name}`, ...skinKeys]; }