easyPlace initial

This commit is contained in:
ForestOfLight
2025-03-15 04:43:11 -07:00
Unverified
parent 830b54e55a
commit 21ec447e0e
6 changed files with 204 additions and 40 deletions
+22 -4
View File
@@ -7,7 +7,7 @@ import { MaterialCounter } from '../classes/MaterialCounter';
const structCmd = new Command({
name: 'struct',
description: { text: 'Manages current StrucTool structures.' },
usage: 'struct',
usage: 'struct <name> <add/remove/place/layer/info> [args...]',
callback: structCommand,
args: [
{ type: 'string', name: 'name' },
@@ -41,7 +41,17 @@ function structCommand(sender, args) {
}
function addStructure(sender, name) {
structureCollection.add(name);
try {
structureCollection.add(name);
} catch (e) {
if (e.message.includes('already exists')) {
sender.sendMessage({ text: `§cStructure '${name}' already exists.` });
return;
} else {
sender.sendMessage({ text: `§cFailed to add structure '${name}'.` });
throw e;
}
}
sender.sendMessage({ text: `§7Added structure '${name}'` });
}
@@ -63,8 +73,16 @@ function placeStructure(sender, name) {
try {
structure = structureCollection.add(name);
} catch (e) {
sender.sendMessage({ text: `§cStructure '${name}' not found.` });
return;
if (e.message.includes('already exists')) {
sender.sendMessage({ text: `§cStructure '${name}' already exists.` });
return;
} else if (e.message.includes('not found')) {
sender.sendMessage({ text: `§cStructure '${name}' not found.` });
return;
} else {
sender.sendMessage({ text: `§cFailed to place structure '${name}'.` });
throw e;
}
}
}
structure.place(sender.dimension.id, sender.location);