@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
78 lines (76 loc) • 4.9 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.StrictPlatformInfoGeneratorTest = void 0;
const ProjectInfoItem_1 = require("./ProjectInfoItem");
const IProjectItemData_1 = require("../app/IProjectItemData");
const IInfoItemData_1 = require("./IInfoItemData");
const EntityTypeDefinition_1 = require("../minecraft/EntityTypeDefinition");
const ItemTypeBehaviorDefinition_1 = require("../minecraft/ItemTypeBehaviorDefinition");
const ProjectInfoUtilities_1 = require("./ProjectInfoUtilities");
var StrictPlatformInfoGeneratorTest;
(function (StrictPlatformInfoGeneratorTest) {
StrictPlatformInfoGeneratorTest[StrictPlatformInfoGeneratorTest["entityTypeUsesAMinecraftIdentifier"] = 100] = "entityTypeUsesAMinecraftIdentifier";
StrictPlatformInfoGeneratorTest[StrictPlatformInfoGeneratorTest["entityTypeUsesAMinecraftRuntimeIdentifier"] = 101] = "entityTypeUsesAMinecraftRuntimeIdentifier";
StrictPlatformInfoGeneratorTest[StrictPlatformInfoGeneratorTest["itemTypeUsesAMinecraftIdentifier"] = 104] = "itemTypeUsesAMinecraftIdentifier";
})(StrictPlatformInfoGeneratorTest = exports.StrictPlatformInfoGeneratorTest || (exports.StrictPlatformInfoGeneratorTest = {}));
class StrictPlatformInfoGenerator {
constructor() {
this.id = "STRICT";
this.title = "Strict Platform Info Generator";
this.canAlwaysProcess = true;
this.identifierOverridesAreErrors = false;
}
getTopicData(topicId) {
return {
title: ProjectInfoUtilities_1.default.getTitleFromEnum(StrictPlatformInfoGeneratorTest, topicId),
};
}
summarize(info, infoSet) { }
async generate(project, contentIndex) {
const infoItems = [];
const itemsCopy = project.getItemsCopy();
for (let i = 0; i < itemsCopy.length; i++) {
const pi = itemsCopy[i];
if (pi.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior) {
await pi.ensureFileStorage();
if (pi.file) {
const bpEntityType = await EntityTypeDefinition_1.default.ensureOnFile(pi.file);
if (bpEntityType) {
await bpEntityType.load();
if (bpEntityType && bpEntityType._data && bpEntityType._data.description) {
const desc = bpEntityType._data.description;
if (desc.identifier !== undefined && desc.identifier.toLowerCase().startsWith("minecraft:")) {
infoItems.push(new ProjectInfoItem_1.default(this.identifierOverridesAreErrors ? IInfoItemData_1.InfoItemType.error : IInfoItemData_1.InfoItemType.warning, this.id, StrictPlatformInfoGeneratorTest.entityTypeUsesAMinecraftIdentifier, `Uses a minecraft: identifier override`, pi, desc.identifier));
}
if (desc.runtime_identifier !== undefined &&
desc.runtime_identifier.toLowerCase !== undefined &&
desc.runtime_identifier.toLowerCase().startsWith("minecraft:")) {
infoItems.push(new ProjectInfoItem_1.default(this.identifierOverridesAreErrors ? IInfoItemData_1.InfoItemType.error : IInfoItemData_1.InfoItemType.warning, this.id, StrictPlatformInfoGeneratorTest.entityTypeUsesAMinecraftRuntimeIdentifier, `Uses a runtime_identifier override`, pi, desc.runtime_identifier));
}
}
}
}
}
else if (pi.itemType === IProjectItemData_1.ProjectItemType.itemTypeBehavior) {
await pi.ensureFileStorage();
if (pi.file) {
const bpItemType = await ItemTypeBehaviorDefinition_1.default.ensureOnFile(pi.file);
if (bpItemType) {
await bpItemType.load();
if (bpItemType && bpItemType.data && bpItemType.data.description) {
const desc = bpItemType.data.description;
if (desc.identifier !== undefined && desc.identifier.toLowerCase().startsWith("minecraft:")) {
infoItems.push(new ProjectInfoItem_1.default(this.identifierOverridesAreErrors ? IInfoItemData_1.InfoItemType.error : IInfoItemData_1.InfoItemType.warning, this.id, StrictPlatformInfoGeneratorTest.itemTypeUsesAMinecraftIdentifier, `Uses a minecraft: identifier override`, pi, desc.identifier));
}
}
}
}
}
}
return infoItems;
}
}
exports.default = StrictPlatformInfoGenerator;
//# sourceMappingURL=../maps/info/StrictPlatformInfoGenerator.js.map