From 395fa5ca6ef4c7585aed576b191f436e99b8924d Mon Sep 17 00:00:00 2001 From: Justin Tracey Date: Mon, 4 Apr 2022 01:48:35 -0400 Subject: [PATCH] add a setting for a minimum permission requirement fixes https://github.com/Sigafoos/journal-links/issues/6 --- scripts/index.js | 9 +++++++++ scripts/journallink.js | 2 ++ 2 files changed, 11 insertions(+) diff --git a/scripts/index.js b/scripts/index.js index ade5049..233d2f1 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -26,6 +26,15 @@ Hooks.on("init", () => { type: String, default: 'h1' }); + game.settings.register(MODULE_NAME, 'minPermission', { + name : 'Minimum permission', + hint: 'A user needs at least this permission level on the destination for a link to be visible.', + scope: 'world', + config: true, + type: String, + choices: Object.keys(CONST.DOCUMENT_PERMISSION_LEVELS), + default: 'LIMITED' + }); game.settings.register(MODULE_NAME, 'debug', { name : 'Debug logging', scope: 'client', diff --git a/scripts/journallink.js b/scripts/journallink.js index bdff937..0fea283 100755 --- a/scripts/journallink.js +++ b/scripts/journallink.js @@ -163,6 +163,8 @@ export class JournalLink { for (let value of values) { let mappedType = this.entityMap[type]; let entity = game[mappedType].get(value); + if (!entity.testUserPermission(game.users.current, game.settings.get('journal-links', 'minPermission'))) + continue; this.debug('adding link from ' + type + ' ' + entity.name); let link = $(''); link.attr('data-entity', type);