bedrock-development
Version:
APIs for creating and editing files related to Minecraft Bedrock development.
52 lines (51 loc) • 2.85 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var _a;
import { MOJANG, MinecraftWorld } from "../../types/index.js";
import { Argument, Option } from "commander";
import { Directories } from "../../file_manager.js";
import { CommandMap } from "../command_map.js";
CommandMap.addCommand("root.world.new", {
parent: (_a = CommandMap.getCommandEntry("root.world")) === null || _a === void 0 ? void 0 : _a.command,
commandOptions(command) {
command
.name("new")
.description("create new world")
.addArgument(new Argument("<name>", "the world name"))
.addOption(new Option("-t, --test", "create a test world with pre-configured gamerules"))
.addOption(new Option("-f, --flat", "create a flat world"))
.addOption(new Option("-m, --mode <gamemode>", "gamemode").choices(["0", "1", "2", "3"]).argParser(parseInt))
.addOption(new Option("-l, --local", "use the local packs in this workspace"))
.addOption(new Option("-b, --bpack <folder name>", "the name of the behavior pack to add"))
.addOption(new Option("-r, --rpack <folder name>", "the name of the resource pack to add"));
},
commandAction: triggerWorldsNew,
});
function triggerWorldsNew(name, options) {
return __awaiter(this, void 0, void 0, function* () {
let behavior_pack_manifest_path = options.bpack;
let resource_pack_manifest_path = options.rpack;
if (options.local) {
behavior_pack_manifest_path = Directories.BEHAVIOR_PATH + 'manifest.json';
resource_pack_manifest_path = Directories.RESOURCE_PATH + 'manifest.json';
}
else {
behavior_pack_manifest_path = MOJANG + '/development_behavior_packs/' + behavior_pack_manifest_path + '/manifest.json';
resource_pack_manifest_path = MOJANG + '/development_resource_packs/' + resource_pack_manifest_path + '/manifest.json';
}
MinecraftWorld.create(name, {
behavior_pack_manifest_path,
resource_pack_manifest_path,
gamemode: options.mode,
flatworld: options.flat,
testworld: options.test,
});
});
}