PermissionCheckEvent¶
Fired whenever any permission system evaluates a permission node. This event cannot be canceled.
Intercept phase — before default logic:
Handlers here may override the outcome by assigning allowed:
-
true: grant permission and stop further propagation -
false: deny permission and stop further propagation -
nil: continue with default logic (default)
Setting allowed to true or false acts as an implicit short-circuit:
no further interceptors or default permission logic will run for this check.
Only nil allows propagation to continue.
Assigning allowed outside of an intercept callback (e.g. in collectors) is ignored.
Example: Let players wearing golden helmets bypass examplemod.someaction.*
local PREFIX = "examplemod.someaction."
spell:intercept({ "PermissionCheckEvent" }, function(evt)
---@cast evt PermissionCheckEvent
if evt.permission:find(PREFIX, 1, true)
and instanceOf(Player, evt.entity)
then
local player = evt.entity ---@cast player Player
local helmet = player:getEquipment("head")
-- grant this permission if wearing a golden helmet;
-- either way, setting allowed stops further propagation
if helmet and helmet.type.id == "golden_helmet" then
evt.allowed = true
else
evt.allowed = false
end
end
end)
-- Keep the spell alive so the interceptor stays active
while true do sleep(20) end
Fields¶
allowed: boolean|nil — Read/Write¶
Optional. Intercept only: set to true to grant, false to deny, or nil to defer to default logic. Any non-nil value stops propagation immediately; assigning allowed in collectors has no effect.
entity: Entity|nil — Read-Only¶
A reference to the entity whose permissions are being checked, or nil if not applicable.
name: string — Read-Only¶
The event's name.
permission: string — Read-Only¶
The permission node being checked.
spell: Spell|nil — Read-Only¶
A reference to the spell that triggered this check, or nil if not linked to a spell.
world: World|nil — Read-Only¶
A reference to the world where the check occurs, or nil if unavailable.