rename /item to /construct and remove ./construct

This commit is contained in:
ForestOfLight
2025-12-29 22:36:43 -08:00
Unverified
parent bdfe4ebd00
commit 2f39c32629
3 changed files with 10 additions and 24 deletions
+5 -15
View File
@@ -1,5 +1,3 @@
import { Command } from '../lib/canopy/CanopyExtension';
import { extension } from '../config';
import { world, system, EntityComponentTypes, ItemStack, CommandPermissionLevel, CustomCommandStatus, Player } from '@minecraft/server';
import { MenuForm } from '../classes/MenuForm';
import { structureCollection } from '../classes/Structure/StructureCollection'
@@ -7,18 +5,10 @@ import { Builders } from '../classes/Builder/Builders';
export const MENU_ITEM = 'construct:menu';
const menuCmd = new Command({
name: 'construct',
description: { translate: 'construct.commands.construct' },
usage: 'construct',
callback: (sender) => openMenu(sender)
});
extension.addCommand(menuCmd);
system.beforeEvents.startup.subscribe((event) => {
const command = {
name: 'construct:item',
description: 'construct.commands.item',
name: 'construct:construct',
description: 'construct.commands.construct',
permissionLevel: CommandPermissionLevel.Any,
cheatsRequired: false
};
@@ -28,13 +18,13 @@ system.beforeEvents.startup.subscribe((event) => {
function givePlayerConstructItem(origin) {
const player = origin.sourceEntity;
if (player instanceof Player === false)
return { status: CustomCommandStatus.Failure, message: 'construct.commands.item.denyorigin' };
return { status: CustomCommandStatus.Failure, message: 'construct.commands.construct.denyorigin' };
system.run(() => {
const givenItemStack = player.getComponent(EntityComponentTypes.Inventory)?.container?.addItem(new ItemStack(MENU_ITEM));
if (givenItemStack)
player.sendMessage({ translate: 'construct.commands.item.fail' });
player.sendMessage({ translate: 'construct.commands.construct.fail' });
else
player.sendMessage({ translate: 'construct.commands.item.success' });
player.sendMessage({ translate: 'construct.commands.construct.success' });
});
return { status: CustomCommandStatus.Success };
}