diff --git a/index.js b/index.js index 64b1aed..26ee163 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ async function main() { await server.watch(); // now mount the plugins - server.plugins.forEach(plugin => plugin.mount()); + server.plugins.forEach((plugin) => plugin.mount()); } main(); diff --git a/squad-server/factory.js b/squad-server/factory.js index 11dd2d9..0709a10 100644 --- a/squad-server/factory.js +++ b/squad-server/factory.js @@ -41,7 +41,10 @@ export default class SquadServerFactory { if (!option.connector) continue; // check the connector is listed in the options - if (!(optionName in pluginConfig)) throw new Error(`${Plugin.name}: ${optionName} (${option.connector} connector) is missing.`); + if (!(optionName in pluginConfig)) + throw new Error( + `${Plugin.name}: ${optionName} (${option.connector} connector) is missing.` + ); // get the name of the connector const connectorName = pluginConfig[optionName]; @@ -50,17 +53,23 @@ export default class SquadServerFactory { if (connectors[connectorName]) continue; // create the connector - connectors[connectorName] = await SquadServerFactory.createConnector(server, option.connector, connectorName, config.connectors[connectorName]) + connectors[connectorName] = await SquadServerFactory.createConnector( + server, + option.connector, + connectorName, + config.connectors[connectorName] + ); } } // initialise plugins Logger.verbose('SquadServerFactory', 1, 'Initialising plugins...'); - for(const pluginConfig of config.plugins) { + for (const pluginConfig of config.plugins) { if (!pluginConfig.enabled) continue; - if (!plugins[pluginConfig.plugin]) throw new Error(`Plugin ${pluginConfig.plugin} does not exist.`); + if (!plugins[pluginConfig.plugin]) + throw new Error(`Plugin ${pluginConfig.plugin} does not exist.`); const Plugin = plugins[pluginConfig.plugin]; @@ -81,7 +90,10 @@ export default class SquadServerFactory { Logger.verbose('SquadServerFactory', 1, `Starting ${type} connector ${connectorName}...`); if (type === 'squadlayerpool') { - return server.squadLayers[connectorConfig.type](connectorConfig.filter, connectorConfig.activeLayerFilter); + return server.squadLayers[connectorConfig.type]( + connectorConfig.filter, + connectorConfig.activeLayerFilter + ); } if (type === 'discord') { @@ -169,18 +181,18 @@ export default class SquadServerFactory {

${option.description}

Default
${
-          typeof option.default === 'object'
-            ? JSON.stringify(option.default, null, 2)
-            : option.default
-        }
`; + typeof option.default === 'object' + ? JSON.stringify(option.default, null, 2) + : option.default + }`; if (option.example) optionInfo += `
Example
${
-            typeof option.example === 'object'
-              ? JSON.stringify(option.example, null, 2)
-              : option.example
-          }
`; + typeof option.example === 'object' + ? JSON.stringify(option.example, null, 2) + : option.example + }`; options.push(optionInfo); } diff --git a/squad-server/index.js b/squad-server/index.js index becc519..da30d77 100644 --- a/squad-server/index.js +++ b/squad-server/index.js @@ -52,7 +52,11 @@ export default class SquadServer extends EventEmitter { } async watch() { - Logger.verbose('SquadServer', 1, `Beginning to watch ${this.options.host}:${this.options.queryPort}...`); + Logger.verbose( + 'SquadServer', + 1, + `Beginning to watch ${this.options.host}:${this.options.queryPort}...` + ); await this.squadLayers.pull(); await this.rcon.connect(); diff --git a/squad-server/plugins/base-plugin.js b/squad-server/plugins/base-plugin.js index a1a6600..331f767 100644 --- a/squad-server/plugins/base-plugin.js +++ b/squad-server/plugins/base-plugin.js @@ -11,8 +11,12 @@ export default class BasePlugin { this.options[optionName] = connectors[this.rawOptions[optionName]]; } else { if (option.required) { - if (!(optionName in this.rawOptions)) throw new Error(`${this.constructor.name}: ${optionName} is required but missing.`); - if (option.default === this.rawOptions[optionName]) throw new Error(`${this.constructor.name}: ${optionName} is required but is the default value.`); + if (!(optionName in this.rawOptions)) + throw new Error(`${this.constructor.name}: ${optionName} is required but missing.`); + if (option.default === this.rawOptions[optionName]) + throw new Error( + `${this.constructor.name}: ${optionName} is required but is the default value.` + ); } this.options[optionName] = this.rawOptions[optionName] || option.default; @@ -41,4 +45,4 @@ export default class BasePlugin { verbose(...args) { Logger.verbose(this.constructor.name, ...args); } -} \ No newline at end of file +} diff --git a/squad-server/plugins/db-log.js b/squad-server/plugins/db-log.js index 9c1d499..4639468 100644 --- a/squad-server/plugins/db-log.js +++ b/squad-server/plugins/db-log.js @@ -30,43 +30,37 @@ export default class DBLog extends BasePlugin { } async prepareToMount() { - this.createModel( - 'Server', - { - id: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true - }, - name: { - type: DataTypes.STRING - } + this.createModel('Server', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + autoIncrement: true + }, + name: { + type: DataTypes.STRING } - ); + }); - this.createModel( - 'TickRate', - { - id: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true - }, - time: { - type: DataTypes.DATE, - notNull: true - }, - tickRate: { - type: DataTypes.FLOAT, - notNull: true - } + this.createModel('TickRate', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + autoIncrement: true + }, + time: { + type: DataTypes.DATE, + notNull: true + }, + tickRate: { + type: DataTypes.FLOAT, + notNull: true } - ); + }); - this.models.Server.hasMany( - this.models.TickRate, - { foreignKey: { name: 'server', allowNull: false }, onDelete: 'CASCADE' } - ); + this.models.Server.hasMany(this.models.TickRate, { + foreignKey: { name: 'server', allowNull: false }, + onDelete: 'CASCADE' + }); await this.models.Server.sync(); await this.models.TickRate.sync(); @@ -96,10 +90,14 @@ export default class DBLog extends BasePlugin { } unmount() { - this.server.removeEventListener('TICK_RATE', this.onTickRate) + this.server.removeEventListener('TICK_RATE', this.onTickRate); } async onTickRate(info) { - await this.models.TickRate.create({ server: this.server.id, time: info.time, tickRate: info.tickRate}); + await this.models.TickRate.create({ + server: this.server.id, + time: info.time, + tickRate: info.tickRate + }); } } diff --git a/squad-server/plugins/discord-admin-cam-logs.js b/squad-server/plugins/discord-admin-cam-logs.js index 658c852..11e9c19 100644 --- a/squad-server/plugins/discord-admin-cam-logs.js +++ b/squad-server/plugins/discord-admin-cam-logs.js @@ -72,7 +72,12 @@ export default class DiscordAdminCamLogs extends DiscordBasePlugin { } async onPlayerUnPossess(info) { - if (info.player === null || info.switchPossess === true || !(info.player.steamID in this.adminsInCam)) return; + if ( + info.player === null || + info.switchPossess === true || + !(info.player.steamID in this.adminsInCam) + ) + return; await this.sendDiscordMessage({ embed: { diff --git a/squad-server/plugins/discord-admin-request.js b/squad-server/plugins/discord-admin-request.js index dc7abd8..c4a989c 100644 --- a/squad-server/plugins/discord-admin-request.js +++ b/squad-server/plugins/discord-admin-request.js @@ -70,7 +70,7 @@ export default class DiscordAdminRequest extends DiscordBasePlugin { } unmount() { - this.server.removeEventListener(`CHAT_COMMAND:${this.options.command}`, this.onChatCommand) + this.server.removeEventListener(`CHAT_COMMAND:${this.options.command}`, this.onChatCommand); } async onChatCommand(info) { @@ -116,10 +116,7 @@ export default class DiscordAdminRequest extends DiscordBasePlugin { } }; - if ( - this.options.pingGroups.length > 0 && - Date.now() - this.options.pingDelay > this.lastPing - ) { + if (this.options.pingGroups.length > 0 && Date.now() - this.options.pingDelay > this.lastPing) { message.content = this.options.pingGroups.map((groupID) => `<@&${groupID}>`).join(' '); this.lastPing = Date.now(); } diff --git a/squad-server/plugins/discord-base-plugin.js b/squad-server/plugins/discord-base-plugin.js index d01180b..9450ac0 100644 --- a/squad-server/plugins/discord-base-plugin.js +++ b/squad-server/plugins/discord-base-plugin.js @@ -19,7 +19,8 @@ export default class DiscordBasePlugin extends BasePlugin { } async sendDiscordMessage(message) { - if (typeof message === 'object' && 'embed' in message) message.embed.footer = { text: COPYRIGHT_MESSAGE }; + if (typeof message === 'object' && 'embed' in message) + message.embed.footer = { text: COPYRIGHT_MESSAGE }; await this.channel.send(message); } diff --git a/squad-server/plugins/discord-rcon.js b/squad-server/plugins/discord-rcon.js index f1eb531..f3f747b 100644 --- a/squad-server/plugins/discord-rcon.js +++ b/squad-server/plugins/discord-rcon.js @@ -83,8 +83,7 @@ export default class DiscordRcon extends BasePlugin { if (!message.member._roles.includes(role)) continue; for (const allowedCommand of allowedCommands) - if (commandPrefix[1].toLowerCase() === allowedCommand.toLowerCase()) - hasPermission = true; + if (commandPrefix[1].toLowerCase() === allowedCommand.toLowerCase()) hasPermission = true; } if (!hasPermission) { diff --git a/squad-server/plugins/discord-server-status.js b/squad-server/plugins/discord-server-status.js index 0c47028..cd412b2 100644 --- a/squad-server/plugins/discord-server-status.js +++ b/squad-server/plugins/discord-server-status.js @@ -44,7 +44,7 @@ export default class DiscordServerStatus extends BasePlugin { constructor(server, options, connectors) { super(server, options, connectors); - this.update = this.update.bind(this); + this.update = this.update.bind(this); } mount() { diff --git a/squad-server/plugins/discord-subsystem-restarter.js b/squad-server/plugins/discord-subsystem-restarter.js index 03a7ad4..5c57e7e 100644 --- a/squad-server/plugins/discord-subsystem-restarter.js +++ b/squad-server/plugins/discord-subsystem-restarter.js @@ -39,7 +39,7 @@ export default class DiscordSubsystemRestarter extends BasePlugin { this.onMessage = this.onMessage.bind(this); } - mount(){ + mount() { this.options.discordClient.on('message', this.onMessage); } @@ -69,6 +69,4 @@ export default class DiscordSubsystemRestarter extends BasePlugin { message.reply('restarted the SquadJS LogParser subsystem.'); } } - - } diff --git a/squad-server/plugins/seeding-mode.js b/squad-server/plugins/seeding-mode.js index fe58ea4..bcce06a 100644 --- a/squad-server/plugins/seeding-mode.js +++ b/squad-server/plugins/seeding-mode.js @@ -55,7 +55,7 @@ export default class SeedingMode extends BasePlugin { } mount() { - this.interval = setInterval(this.broadcast, this.options.interval); + this.interval = setInterval(this.broadcast, this.options.interval); } unmount() { @@ -63,10 +63,7 @@ export default class SeedingMode extends BasePlugin { } async broadcast() { - if ( - this.server.a2sPlayerCount !== 0 && - this.server.a2sPlayerCount < this.options.liveThreshold - ) + if (this.server.a2sPlayerCount !== 0 && this.server.a2sPlayerCount < this.options.liveThreshold) await this.server.rcon.broadcast(this.options.seedingMessage); else if ( this.server.a2sPlayerCount !== 0 &&