placeschematic command
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user