forked from Team-Silver-Sphere/SquadJS
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90540f0
commit 95b8baf
Showing
4 changed files
with
58 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,36 @@ | ||
import AutoKickUnassigned from './auto-kick-unassigned.js'; | ||
import AutoTKWarn from './auto-tk-warn.js'; | ||
import ChatCommands from './chat-commands.js'; | ||
import DBLog from './db-log.js'; | ||
import DiscordAdminBroadcast from './discord-admin-broadcast.js'; | ||
import DiscordAdminCamLogs from './discord-admin-cam-logs.js'; | ||
import DiscordAdminRequest from './discord-admin-request.js'; | ||
import DiscordChat from './discord-chat.js'; | ||
import DiscordDebug from './discord-debug.js'; | ||
import DiscordRcon from './discord-rcon.js'; | ||
import DiscordRoundWinner from './discord-round-winner.js'; | ||
import DiscordServerStatus from './discord-server-status.js'; | ||
import DiscordSubsystemRestarter from './discord-subsystem-restarter.js'; | ||
import DiscordTeamkill from './discord-teamkill.js'; | ||
import IntervalledBroadcasts from './intervalled-broadcasts.js'; | ||
import SCBLInfo from './scbl-info.js'; | ||
import SeedingMode from './seeding-mode.js'; | ||
import TeamRandomizer from './team-randomizer.js'; | ||
|
||
const plugins = [ | ||
AutoKickUnassigned, | ||
AutoTKWarn, | ||
ChatCommands, | ||
DBLog, | ||
DiscordAdminBroadcast, | ||
DiscordAdminCamLogs, | ||
DiscordAdminRequest, | ||
DiscordChat, | ||
DiscordDebug, | ||
DiscordRcon, | ||
DiscordRoundWinner, | ||
DiscordServerStatus, | ||
DiscordSubsystemRestarter, | ||
DiscordTeamkill, | ||
IntervalledBroadcasts, | ||
SCBLInfo, | ||
SeedingMode, | ||
TeamRandomizer | ||
]; | ||
|
||
const pluginsByName = {}; | ||
for (const plugin of plugins) { | ||
pluginsByName[plugin.name] = plugin; | ||
import fs from 'fs'; | ||
|
||
import Logger from 'core/logger'; | ||
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
class Plugins { | ||
constructor() { | ||
this.plugins = null; | ||
} | ||
|
||
async getPlugins(force = false) { | ||
if (this.plugins && !force) return this.plugins; | ||
|
||
this.plugins = {}; | ||
|
||
const dir = await fs.promises.opendir(path.join(__dirname, './')); | ||
for await (const dirent of dir) { | ||
if (!dirent.isFile()) continue; | ||
if ( | ||
['index.js', 'base-plugin.js', 'discord-base-plugin.js', 'readme.md'].includes(dirent.name) | ||
) | ||
continue; | ||
Logger.verbose('Plugins', 1, `Loading plugin file ${dirent.name}...`); | ||
const { default: Plugin } = await import(`./${dirent.name}`); | ||
|
||
this.plugins[Plugin.name] = Plugin; | ||
} | ||
|
||
return this.plugins; | ||
} | ||
} | ||
|
||
export default pluginsByName; | ||
export default new Plugins(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import SquadServerFactory from '../factory.js'; | ||
|
||
console.log('Building config...'); | ||
SquadServerFactory.buildConfigFile(); | ||
console.log('Done.'); | ||
SquadServerFactory.buildConfigFile() | ||
.then(() => { | ||
console.log('Done.'); | ||
}) | ||
.catch(console.log); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import SquadServerFactory from '../factory.js'; | ||
|
||
console.log('Building readme...'); | ||
SquadServerFactory.buildReadmeFile(); | ||
console.log('Done.'); | ||
SquadServerFactory.buildReadmeFile() | ||
.then(() => { | ||
console.log('Done.'); | ||
}) | ||
.catch(console.log); |