placeschematic command

This commit is contained in:
2026-11-21 09:16:51 -03:00
parent c4eda256a1
commit 04c9511b6c
4 changed files with 41 additions and 1 deletions
+23
View File
@@ -1882,6 +1882,29 @@ export class GameServer {
.then(coordinates(["x1", "y1", "z1", "x2", "y2", "z2"], (context) => this.#export_schematic(context))),
);
// TODO: only let operators do this
register(
literal<ServerCommandSource>("placeschematic")
.describe("Places a schematic with its lowest corner at x y z")
.then(
argument<string, ServerCommandSource>("schematic", word())
.suggests((partial) =>
[...this.schematics.keys()].filter((id) => id.startsWith(partial)).map((text) => ({ text }))
)
.then(coordinates(["x", "y", "z"], (context) => {
const id = context.get<string>("schematic");
if (!this.schematics.has(id)) throw new CommandError(`There's no schematic ${id}`);
const [x, y, z] = ["x", "y", "z"].map((axis) => context.get<number>(axis));
try {
this.place_schematic(id, { position: { x, y, z } });
} catch (e) {
throw new CommandError(`Couldn't place it: ${(e as Error).message}`);
}
context.source.send_message(`Placed ${id} at ${x} ${y} ${z}`);
})),
),
);
// TODO: only let operators do this
register(
literal<ServerCommandSource>("fill")