let vpnExceptionIds = []; const vpnAllowListKey = 'Webfront::Nav::Admin::VPNAllowList'; const vpnWhitelistKey = 'Webfront::Profile::VPNWhitelist'; const init = (registerNotify, serviceResolver, config) => { registerNotify('IManagementEventSubscriptions.ClientStateAuthorized', (authorizedEvent, _) => plugin.onClientAuthorized(authorizedEvent)); plugin.onLoad(serviceResolver, config); return plugin; }; const plugin = { author: 'RaidMax', version: '1.6', name: 'VPN Detection Plugin', manager: null, config: null, logger: null, serviceResolver: null, translations: null, commands: [{ name: 'whitelistvpn', description: 'whitelists a player\'s client id from VPN detection', alias: 'wv', permission: 'SeniorAdmin', targetRequired: true, arguments: [{ name: 'player', required: true }], execute: (gameEvent) => { vpnExceptionIds.push(gameEvent.Target.ClientId); plugin.config.setValue('vpnExceptionIds', vpnExceptionIds); gameEvent.origin.tell(`Successfully whitelisted ${gameEvent.target.name}`); } }, { name: 'disallowvpn', description: 'disallows a player from connecting with a VPN', alias: 'dv', permission: 'SeniorAdmin', targetRequired: true, arguments: [{ name: 'player', required: true }], execute: (gameEvent) => { vpnExceptionIds = vpnExceptionIds.filter(exception => parseInt(exception) !== parseInt(gameEvent.Target.ClientId)); plugin.config.setValue('vpnExceptionIds', vpnExceptionIds); gameEvent.origin.tell(`Successfully disallowed ${gameEvent.target.name} from connecting with VPN`); } } ], interactions: [{ // registers the profile action name: vpnWhitelistKey, action: function(targetId, game, token) { const helpers = importNamespace('SharedLibraryCore.Helpers'); const interactionData = new helpers.InteractionData(); interactionData.actionPath = 'DynamicAction'; interactionData.interactionId = vpnWhitelistKey; interactionData.entityId = targetId; interactionData.minimumPermission = 3; interactionData.source = plugin.name; interactionData.actionMeta.add('InteractionId', 'command'); // indicate we're wanting to execute a command interactionData.actionMeta.add('ShouldRefresh', true.toString()); // indicates that the page should refresh after performing the action if (vpnExceptionIds.includes(targetId)) { interactionData.name = plugin.translations['WEBFRONT_VPN_BUTTON_DISALLOW']; // text for the profile button interactionData.displayMeta = 'oi-circle-x'; interactionData.actionMeta.add('Data', `disallowvpn`); // command to execute interactionData.actionMeta.add('ActionButtonLabel', plugin.translations['WEBFRONT_VPN_ACTION_DISALLOW_CONFIRM']); // confirm button on the dialog interactionData.actionMeta.add('Name', plugin.translations['WEBFRONT_VPN_ACTION_DISALLOW_TITLE']); // title on the confirm dialog } else { interactionData.name = plugin.translations['WEBFRONT_VPN_ACTION_ALLOW']; // text for the profile button interactionData.displayMeta = 'oi-circle-check'; interactionData.actionMeta.add('Data', `whitelistvpn`); // command to execute interactionData.actionMeta.add('ActionButtonLabel', plugin.translations['WEBFRONT_VPN_ACTION_ALLOW_CONFIRM']); // confirm button on the dialog interactionData.actionMeta.add('Name', plugin.translations['WEBFRONT_VPN_ACTION_ALLOW_TITLE']); // title on the confirm dialog } return interactionData; } }, { name: vpnAllowListKey, action: function(targetId, game, token) { const helpers = importNamespace('SharedLibraryCore.Helpers'); const interactionData = new helpers.InteractionData(); interactionData.name = plugin.translations['WEBFRONT_NAV_VPN_TITLE']; // navigation link name interactionData.description = plugin.translations['WEBFRONT_NAV_VPN_DESC']; // alt and title interactionData.displayMeta = 'oi-circle-check'; // nav icon interactionData.interactionId = vpnAllowListKey; interactionData.minimumPermission = 3; // moderator interactionData.interactionType = 2; // 1 is RawContent for apis etc..., 2 is interactionData.source = plugin.name; interactionData.scriptAction = (sourceId, targetId, game, meta, token) => { const clientsData = plugin.getClientsData(vpnExceptionIds); let table = '
No players are whitelisted. | |
${client.currentAlias.name.stripColors()} |
${plugin.translations['WEBFRONT_VPN_BUTTON_DISALLOW']}
|