mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 23:33:13 +09:00
Prefix clusterio/lib imports with lib
Use lib* prefix for the modules impored from the lib package to help distinguish them more from ordinary variables. Fix up the naming convention for files to be consistently lowercase_underscore for JavaScript files.
This commit is contained in:
1 parent
fbbaf3dd3a
commit
24397b75cc
55 files changed
+692
-668
No files matched your search
@@ -1,11 +1,13 @@
|
||||
"use strict";
|
||||
const plugin = require("@clusterio/lib/plugin");
|
||||
const libPlugin = require("@clusterio/lib/plugin");
|
||||
const info = require("./info");
|
||||
const command = require("@clusterio/lib/command");
|
||||
const libCommand = require("@clusterio/lib/command");
|
||||
|
||||
|
||||
const globalChatCommands = new command.CommandTree({ name: "global-chat", description: "Global Chat plugin commands" });
|
||||
globalChatCommands.add(new command.Command({
|
||||
const globalChatCommands = new libCommand.CommandTree({
|
||||
name: "global-chat", description: "Global Chat plugin commands",
|
||||
});
|
||||
globalChatCommands.add(new libCommand.Command({
|
||||
definition: ["shout <message>", "Send message to all instances", (yargs) => {
|
||||
yargs.positional("message", { describe: "message to send", type: "string" });
|
||||
}],
|
||||
@@ -17,7 +19,7 @@ globalChatCommands.add(new command.Command({
|
||||
},
|
||||
}));
|
||||
|
||||
class ControlPlugin extends plugin.BaseControlPlugin {
|
||||
class ControlPlugin extends libPlugin.BaseControlPlugin {
|
||||
async addCommands(rootCommand) {
|
||||
rootCommand.add(globalChatCommands);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
let link = require("@clusterio/lib/link");
|
||||
let plugin = require("@clusterio/lib/plugin");
|
||||
let libLink = require("@clusterio/lib/link");
|
||||
|
||||
module.exports = {
|
||||
name: "global_chat",
|
||||
@@ -10,7 +9,7 @@ module.exports = {
|
||||
controlEntrypoint: "control",
|
||||
|
||||
messages: {
|
||||
chat: new link.Event({
|
||||
chat: new libLink.Event({
|
||||
type: "global_chat:chat",
|
||||
links: ["instance-slave", "slave-master", "master-slave", "slave-instance", "control-master"],
|
||||
forwardTo: "master",
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* @module
|
||||
*/
|
||||
"use strict";
|
||||
const plugin = require("@clusterio/lib/plugin");
|
||||
const luaTools = require("@clusterio/lib/luaTools");
|
||||
const libPlugin = require("@clusterio/lib/plugin");
|
||||
const libLuaTools = require("@clusterio/lib/lua_tools");
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,7 +16,7 @@ function removeTags(content) {
|
||||
return content.replace(/(\[gps=-?\d+,-?\d+\]|\[train=\d+\])/g, "");
|
||||
}
|
||||
|
||||
class InstancePlugin extends plugin.BaseInstancePlugin {
|
||||
class InstancePlugin extends libPlugin.BaseInstancePlugin {
|
||||
async init() {
|
||||
this.messageQueue = [];
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class InstancePlugin extends plugin.BaseInstancePlugin {
|
||||
async chatEventHandler(message) {
|
||||
// TODO check if cross server chat is enabled
|
||||
let content = `[${message.data.instance_name}] ${removeTags(message.data.content)}`;
|
||||
await this.instance.server.sendRcon(`/sc game.print('${luaTools.escapeString(content)}')`, true);
|
||||
await this.instance.server.sendRcon(`/sc game.print('${libLuaTools.escapeString(content)}')`, true);
|
||||
}
|
||||
|
||||
sendChat(message) {
|
||||
|
||||
Reference in new issue
Block a user