From 3554ad1b9ad9d9dbc87f57cc993e5fa256d1d129 Mon Sep 17 00:00:00 2001 From: IgnisAlienus Date: Fri, 26 Jul 2024 13:18:49 -0500 Subject: [PATCH 1/2] feat: asset claims plugin --- squad-server/plugins/asset-claims.js | 79 ++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 squad-server/plugins/asset-claims.js diff --git a/squad-server/plugins/asset-claims.js b/squad-server/plugins/asset-claims.js new file mode 100644 index 00000000..7dc9816b --- /dev/null +++ b/squad-server/plugins/asset-claims.js @@ -0,0 +1,79 @@ +import BasePlugin from './base-plugin.js'; + +export default class AssetClaims extends BasePlugin { + static get description() { + return 'The AssetClaims plugin will prevent Squads with certain names from being created.'; + } + + static get defaultEnabled() { + return false; + } + + static get optionsSpecification() { + return { + disallowedNames: { + required: false, + description: 'Squad Names that are not allowed.', + default: [ + "TANK", + "TONK", + "CHADLEY", + "CHALLY", + "HELIS", + "HELI", + "HELO", + "HELICOPTER", + "ARMOR", + "IFV", + "MBT", + "SCOUT", + "TNAK", + "PILOT" + ], + example: ['TANK', 'TONK', 'HELI'] + }, + warningMessage: { + required: false, + description: 'AdminWarn Message to send to the Player that created the Squad.', + default: 'Please name your Vehicle Squad more specifically.\nSuch as T-72 instead of TANK', + example: 'Please name your Vehicle Squad more specifically.\nSuch as T-72 instead of TANK' + }, + disbandTimeout: { + required: false, + description: 'Time in milliseconds to wait before disbanding the Squad after the AdminWarn.', + default: 5000, + } + }; + } + + constructor(server, options, connectors) { + super(server, options, connectors); + + this.onSquadCreated = this.onSquadCreated.bind(this); + } + + async mount() { + this.server.on('SQUAD_CREATED', this.onSquadCreated); + } + + async unmount() { + this.server.removeEventListener('SQUAD_CREATED', this.onSquadCreated); + } + + async onSquadCreated(info) { + // Regular expression to check if the info.squadName contains any of the words in the disallowedNames config array, case insensitive + const regex = new RegExp(this.options.disallowedNames.map(name => name.toLowerCase()).join('|'), 'i'); + + // If the above regex is a match to the config array, send a warning message using rcon.warn + if (regex.test(info.squadName.toLowerCase())) { + await this.server.rcon.warn(info.player.steamID, this.options.warningMessage); + this.verbose( + 1, + `Disbanding Team ${info.player.teamID} - Squad ${info.squadID} - Named: ${info.squadName}` + ); + setTimeout(async () => { + await this.server.rcon.disbandSquad(info.player.teamID, info.squadID); + }, this.options.disbandTimeout); + } + } +} \ No newline at end of file From 8a0e1b565c73134f7cfed6da2fd972aa78898acc Mon Sep 17 00:00:00 2001 From: IgnisAlienus Date: Fri, 26 Jul 2024 13:21:33 -0500 Subject: [PATCH 2/2] feat: add PSG - Ignis plugin --- squad-server/plugins/asset-claims.js | 1 + 1 file changed, 1 insertion(+) diff --git a/squad-server/plugins/asset-claims.js b/squad-server/plugins/asset-claims.js index 7dc9816b..64516934 100644 --- a/squad-server/plugins/asset-claims.js +++ b/squad-server/plugins/asset-claims.js @@ -1,3 +1,4 @@ +//Plugin by PSG - Ignis import BasePlugin from './base-plugin.js'; export default class AssetClaims extends BasePlugin {