2023-04-04 19:24:13 -04:00
|
|
|
const init = (registerNotify, serviceResolver, config) => {
|
|
|
|
registerNotify('IManagementEventSubscriptions.ClientPenaltyAdministered', (penaltyEvent, _) => plugin.onClientPenalty(penaltyEvent));
|
|
|
|
|
|
|
|
plugin.onLoad(serviceResolver, config);
|
|
|
|
return plugin;
|
2022-06-01 16:03:26 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const plugin = {
|
2023-04-04 19:24:13 -04:00
|
|
|
author: 'Amos, RaidMax',
|
|
|
|
version: '2.0',
|
2022-06-01 16:03:26 -04:00
|
|
|
name: 'Broadcast Bans',
|
2023-04-04 19:24:13 -04:00
|
|
|
config: null,
|
|
|
|
logger: null,
|
|
|
|
translations: null,
|
|
|
|
manager: null,
|
2022-06-01 16:03:26 -04:00
|
|
|
|
2023-04-04 19:24:13 -04:00
|
|
|
onClientPenalty: function (penaltyEvent) {
|
2023-04-05 15:12:59 -04:00
|
|
|
if (!this.enableBroadcastBans || penaltyEvent.penalty.type !== 5) {
|
2022-06-01 16:03:26 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-04-04 19:24:13 -04:00
|
|
|
let automatedPenaltyMessage;
|
|
|
|
|
|
|
|
penaltyEvent.penalty.punisher.administeredPenalties?.forEach(penalty => {
|
|
|
|
automatedPenaltyMessage = penalty.automatedOffense;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (penaltyEvent.penalty.punisher.clientId === 1 && automatedPenaltyMessage !== undefined) {
|
|
|
|
let message = this.translations['PLUGINS_BROADCAST_BAN_ACMESSAGE'].replace('{{targetClient}}', penaltyEvent.client.cleanedName);
|
|
|
|
this.broadcastMessage(message);
|
|
|
|
} else {
|
|
|
|
let message = this.translations['PLUGINS_BROADCAST_BAN_MESSAGE'].replace('{{targetClient}}', penaltyEvent.client.cleanedName);
|
|
|
|
this.broadcastMessage(message);
|
2022-06-01 16:03:26 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-04-04 19:24:13 -04:00
|
|
|
broadcastMessage: function (message) {
|
|
|
|
this.manager.getServers().forEach(server => {
|
|
|
|
server.broadcast(message);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onLoad: function (serviceResolver, config) {
|
|
|
|
this.config = config;
|
|
|
|
this.config.setName(this.name);
|
|
|
|
this.enableBroadcastBans = this.config.getValue('EnableBroadcastBans');
|
|
|
|
|
|
|
|
this.manager = serviceResolver.resolveService('IManager');
|
|
|
|
this.logger = serviceResolver.resolveService('ILogger', ['ScriptPluginV2']);
|
|
|
|
this.translations = serviceResolver.resolveService('ITranslationLookup');
|
2022-06-01 16:03:26 -04:00
|
|
|
|
|
|
|
if (this.enableBroadcastBans === undefined) {
|
|
|
|
this.enableBroadcastBans = false;
|
2023-04-04 19:24:13 -04:00
|
|
|
this.config.setValue('EnableBroadcastBans', this.enableBroadcastBans);
|
2022-06-01 16:03:26 -04:00
|
|
|
}
|
|
|
|
|
2023-04-04 19:24:13 -04:00
|
|
|
this.logger.logInformation('{Name} {Version} by {Author} loaded. Enabled={enabled}', this.name, this.version,
|
|
|
|
this.author, this.enableBroadcastBans);
|
2022-06-01 16:03:26 -04:00
|
|
|
}
|
|
|
|
};
|