mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Move BaseControllerPlugin to controller/src/BaseControllerPlugin.ts Move BaseInstancePlugin to host/src/BaseInstancePlugin.ts Move BaseControlPlugin to ctl/src/BaseCtlPlugin.ts Move BaseWebPlugin to web_ui/src/BaseWebPlugin.ts This solves the circular package dependency problem of the base plugins needing types that are available only in the dependencies to lib.
22 lines
730 B
TypeScript
22 lines
730 B
TypeScript
import { CommandTree, Command } from "@clusterio/lib";
|
|
import { BaseCtlPlugin } from "@clusterio/ctl";
|
|
import { ChatEvent } from "./messages";
|
|
|
|
const globalChatCommands = new CommandTree({
|
|
name: "global-chat", description: "Global Chat plugin commands",
|
|
});
|
|
globalChatCommands.add(new Command({
|
|
definition: ["shout <message>", "Send message to all instances", (yargs) => {
|
|
yargs.positional("message", { describe: "message to send", type: "string" });
|
|
}],
|
|
handler: async function(args, control) {
|
|
await control.sendTo("allInstances", new ChatEvent("Console", args.message));
|
|
},
|
|
}));
|
|
|
|
export class CtlPlugin extends BaseCtlPlugin {
|
|
async addCommands(rootCommand: CommandTree) {
|
|
rootCommand.add(globalChatCommands);
|
|
}
|
|
}
|