UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

66 lines (65 loc) 3.72 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.UnlinkedItemNotFoundByType = exports.UnlinkedItemInfoGeneratorTest = void 0; const ProjectInfoItem_1 = __importDefault(require("./ProjectInfoItem")); const ProjectItemUtilities_1 = __importDefault(require("../app/ProjectItemUtilities")); const IInfoItemData_1 = require("./IInfoItemData"); const Database_1 = __importDefault(require("../minecraft/Database")); const IProjectItemData_1 = require("../app/IProjectItemData"); var UnlinkedItemInfoGeneratorTest; (function (UnlinkedItemInfoGeneratorTest) { UnlinkedItemInfoGeneratorTest[UnlinkedItemInfoGeneratorTest["unlinkedItemIsNotUsed"] = 191] = "unlinkedItemIsNotUsed"; UnlinkedItemInfoGeneratorTest[UnlinkedItemInfoGeneratorTest["avoidLinksToVanillaItems"] = 205] = "avoidLinksToVanillaItems"; })(UnlinkedItemInfoGeneratorTest || (exports.UnlinkedItemInfoGeneratorTest = UnlinkedItemInfoGeneratorTest = {})); exports.UnlinkedItemNotFoundByType = 300; /** * Detects unlinked items and validates item relationships. * * @see {@link ../../public/data/forms/mctoolsval/unlink.form.json} for topic definitions */ class UnlinkedItemInfoGenerator { id = "UNLINK"; title = "Unlinked Items"; canAlwaysProcess = true; summarize(info, infoSet) { } async generate(projectItem, contentIndex) { const items = []; if (projectItem.unfulfilledRelationships) { for (const rel of projectItem.unfulfilledRelationships) { if (rel.isVanillaDependent) { // UNLINK205 items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.recommendation, this.id, UnlinkedItemInfoGeneratorTest.avoidLinksToVanillaItems, `Link to vanilla ` + ProjectItemUtilities_1.default.getDescriptionForType(rel.itemType).toLowerCase() + ` item; avoid if possible`, projectItem, rel.path)); } else { const message = `Link to ` + ProjectItemUtilities_1.default.getDescriptionForType(rel.itemType).toLowerCase() + ` is not found in this pack`; // UNLINK300+ items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.warning, this.id, exports.UnlinkedItemNotFoundByType + rel.itemType, message, projectItem, projectItem.projectPath + " to `" + rel.path + "`")); } } } if (projectItem.itemType === IProjectItemData_1.ProjectItemType.texture || projectItem.itemType === IProjectItemData_1.ProjectItemType.audio) { if (projectItem.parentItemCount <= 0 && projectItem.childItemCount <= 0) { const path = await projectItem.getPackRelativePath(); if (path) { const isVanilla = await Database_1.default.matchesVanillaPath(path); if (!isVanilla) { // UNLINK191 items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.warning, this.id, UnlinkedItemInfoGeneratorTest.unlinkedItemIsNotUsed, ProjectItemUtilities_1.default.getDescriptionForType(projectItem.itemType) + ` does not have any items in this pack that are using this.`, projectItem)); } } } } return items; } } exports.default = UnlinkedItemInfoGenerator;