Prevent non-GMs from making attributes when the setting is disabled.
This commit is contained in:
parent
d22cd83bf3
commit
47892d116b
2 changed files with 12 additions and 1 deletions
|
|
@ -137,7 +137,8 @@
|
||||||
"invalid-socket": "Invalid socket data received, this means a module or system bug is present.",
|
"invalid-socket": "Invalid socket data received, this means a module or system bug is present.",
|
||||||
"unknown-socket-event": "An unknown socket event was received: {event}",
|
"unknown-socket-event": "An unknown socket event was received: {event}",
|
||||||
"duplicate-attribute-key": "Cannot create an Attribute with a key (\"{key}\") that already exists on the Actor",
|
"duplicate-attribute-key": "Cannot create an Attribute with a key (\"{key}\") that already exists on the Actor",
|
||||||
"invalid-attribute-key": "Attribute keys must be alphanumeric (a-z, 0-9) with underscores, invalid key provided: \"{key}\""
|
"invalid-attribute-key": "Attribute keys must be alphanumeric (a-z, 0-9) with underscores, invalid key provided: \"{key}\"",
|
||||||
|
"cant-manage-attributes": "You aren't allowed to manage attributes. Talk to your GM for permission or to get them to add the attribute for you."
|
||||||
},
|
},
|
||||||
"warn": {
|
"warn": {
|
||||||
"migration-in-progress": "Applying data migrations for version {version}. Please do NOT refresh the window while this warning is present."
|
"migration-in-progress": "Applying data migrations for version {version}. Please do NOT refresh the window while this warning is present."
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { isValidID, toID } from "../../utils/toID.mjs";
|
import { isValidID, toID } from "../../utils/toID.mjs";
|
||||||
|
import { __ID__ } from "../../consts.mjs";
|
||||||
import { clamp } from "../../utils/clamp.mjs";
|
import { clamp } from "../../utils/clamp.mjs";
|
||||||
|
|
||||||
const { getProperty, hasProperty, setProperty } = foundry.utils;
|
const { getProperty, hasProperty, setProperty } = foundry.utils;
|
||||||
|
|
@ -41,6 +42,15 @@ export class AttributeItemData extends foundry.abstract.TypeDataModel {
|
||||||
|
|
||||||
// #region Lifecycle
|
// #region Lifecycle
|
||||||
async _preCreate(data, options, user) {
|
async _preCreate(data, options, user) {
|
||||||
|
// Prevent users from creating attributes if disallowed
|
||||||
|
if (
|
||||||
|
!game.settings.get(__ID__, `canPlayersManageAttributes`)
|
||||||
|
&& !user.isGM
|
||||||
|
) {
|
||||||
|
ui.notifications.error(_loc(`taf.notifs.error.cant-manage-attributes`));
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
// Assign the key as the ID'd name if isn't provided, or validate if
|
// Assign the key as the ID'd name if isn't provided, or validate if
|
||||||
// it is provided.
|
// it is provided.
|
||||||
if (!this.key) {
|
if (!this.key) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue