Move the tweak prevention into a helper function and rename the module hooks w/ compatibility code
This commit is contained in:
parent
3d4376aa81
commit
9c8b6f37f9
20 changed files with 102 additions and 102 deletions
24
module/utils/preRegisterTweak.mjs
Normal file
24
module/utils/preRegisterTweak.mjs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { SettingStatusEnum, status } from "./SettingStatus.mjs";
|
||||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "./Logger.mjs";
|
||||
|
||||
export function preventTweakRegistration(key, invasive = false) {
|
||||
let prevented = Hooks.call(`${__ID__}.preRegisterTweak`, key, invasive);
|
||||
|
||||
// Compatibility Code
|
||||
if (Hooks.events[`${__ID__}.preventSetting`] != null) {
|
||||
foundry.utils.logCompatibilityWarning(
|
||||
`The hook "${__ID__}.preventSetting" has been renamed "${__ID__}.registerTweak".`,
|
||||
{ since: `v1.2.0`, until: `v2.0.0`, stack: false, once: true },
|
||||
);
|
||||
prevented &&= Hooks.call(`${__ID__}.preventSetting`);
|
||||
};
|
||||
|
||||
if (!prevented) {
|
||||
Logger.log(`Preventing setting "${key}" from being registered`);
|
||||
status[key] = SettingStatusEnum.Blocked;
|
||||
return true;
|
||||
};
|
||||
|
||||
return false;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue