Test mod
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import type { ServerContext } from "bworld/server";
|
||||
|
||||
// called once when the server starts
|
||||
export function setup(ctx: ServerContext) {
|
||||
// used by blocks/example_block.json, which passes { message } as params
|
||||
ctx.components.register_block<{ message: string }>("example_mod:announce", {
|
||||
on_interact(_block, params, player) {
|
||||
player.send_message(params.message);
|
||||
// handled, so right clicking it doesn't place a block
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
// /example_mod:hello, or /hello when no other mod uses that name
|
||||
ctx.commands.register("hello", {
|
||||
description: "Say hello",
|
||||
usage: "/hello",
|
||||
run(_args, player) {
|
||||
player.send_message(`Hello ${player.name}!`);
|
||||
},
|
||||
});
|
||||
|
||||
ctx.events.after.player_join.subscribe(({ player }) => {
|
||||
ctx.log(`${player.name} joined`);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user