mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Move all functions and classes currently available through lib/name and libName to be under a single flat namespace in lib. This make reorganising the lib namespace much simpler as the location of symbols can move without breaking the consumers of lib. The multi-entrypoint design was already problematic for the web plugin system which couldn't effectively use it due to how webpack's shared module system is awkward to set up with multiple entrypoints per package.
27 lines
753 B
JavaScript
27 lines
753 B
JavaScript
"use strict";
|
|
const { BaseControlPlugin, CommandTree, Command } = require("@clusterio/lib");
|
|
const { ChatEvent } = require("./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));
|
|
},
|
|
}));
|
|
|
|
class ControlPlugin extends BaseControlPlugin {
|
|
async addCommands(rootCommand) {
|
|
rootCommand.add(globalChatCommands);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
ControlPlugin,
|
|
};
|