EventInterceptor¶
Represents an interceptor for events.
An event interceptor is returned by spell:intercept() and allows inline handling of events as they occur.
Unlike an event queue, an interceptor can cancel events by returning false from its callback function (if the event supports cancellation).
Example: Canceling a death event
local i = spell:intercept({ "BeforeLivingEntityDeathEvent" }, function(evt)
if evt.entity.type.id == "zombie" then
evt.entity.health = 1
return false -- Cancel the death
end
return true
end)
while true do sleep(20) end -- Keep spell running
Fields¶
names: table — Read-Only¶
The names of the events that this interceptor listens to.