@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
82 lines (80 loc) • 3.75 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
const Log_1 = require("../core/Log");
const CommandRegistry_1 = require("./CommandRegistry");
const ICommand_1 = require("./ICommand");
class CartoCommands {
static async debugProjectInformation(context, name, args) {
if (!context.project) {
return { status: ICommand_1.CommandStatus.invalidArguments };
}
let message = "N: " + context.project.name;
if (context.project.projectFolder) {
message += " PF: " + context.project.projectFolder.fullPath;
}
Log_1.default.message(message);
return { status: ICommand_1.CommandStatus.completed };
}
static async debugMinecraft(context, name, args) {
let message = "LAM: " + context.carto.lastActiveMinecraftFlavor;
if (context.carto.remoteServerUrl) {
message += " RSURL: " + context.carto.remoteServerUrl;
}
if (context.carto.remoteServerPort) {
message += " RSP: " + context.carto.remoteServerPort;
}
if (context.carto.dedicatedServerMode) {
message += " DSM: " + context.carto.dedicatedServerMode;
}
if (context.carto.dedicatedServerPath) {
message += " DSP: " + context.carto.dedicatedServerPath;
}
if (context.carto.dedicatedServerSlotCount) {
message += " DSS: " + context.carto.dedicatedServerSlotCount;
}
Log_1.default.message(message);
return { status: ICommand_1.CommandStatus.completed };
}
static async startMinecraft(context, name, args) {
if (!context.minecraft && !context.carto.lastActiveMinecraftFlavor) {
return { status: ICommand_1.CommandStatus.invalidEnvironment };
}
let mc = context.minecraft;
if (!mc && context.carto.lastActiveMinecraftFlavor) {
mc = context.carto.ensureMinecraft(context.carto.lastActiveMinecraftFlavor);
}
if (!mc) {
return { status: ICommand_1.CommandStatus.invalidEnvironment };
}
Log_1.default.message("Starting server.");
await mc.prepareAndStart({
project: context.project,
});
return { status: ICommand_1.CommandStatus.completed };
}
static async stopMinecraft(context, name, args) {
if (!context.minecraft) {
return { status: ICommand_1.CommandStatus.invalidEnvironment };
}
Log_1.default.message("Stopping server.");
await context.minecraft.stop();
return { status: ICommand_1.CommandStatus.completed };
}
static async updateMinecraft(context, name, args) {
if (context.minecraft) {
context.minecraft.prepare(true);
}
return { status: ICommand_1.CommandStatus.completed };
}
static registerCommonCommands() {
CommandRegistry_1.default.main.registerCommand("dbgproj", CommandRegistry_1.CommandScope.debug, CartoCommands.debugProjectInformation);
CommandRegistry_1.default.main.registerCommand("dbgmc", CommandRegistry_1.CommandScope.debug, CartoCommands.debugMinecraft);
CommandRegistry_1.default.main.registerCommand("startmc", CommandRegistry_1.CommandScope.any, CartoCommands.startMinecraft);
CommandRegistry_1.default.main.registerCommand("stopmc", CommandRegistry_1.CommandScope.minecraft, CartoCommands.stopMinecraft);
CommandRegistry_1.default.main.registerCommand("updatemc", CommandRegistry_1.CommandScope.minecraft, CartoCommands.updateMinecraft);
}
}
exports.default = CartoCommands;
//# sourceMappingURL=../maps/app/CartoCommands.js.map