Skip to content

SpellFinishedEvent

Triggered when a spell ends, however that happens: it has run to its end, it failed with an error, or it was broken, for example with /wol spell break. This event cannot be canceled.

All spells get this event, so check spell to see which one it is about. An interceptor of the spell itself runs while that spell is still there, with its sockets and files still open, which makes it the place to clean up. It must not wait, as nothing can wake it up again.

Example: Clean up when the spell ends

spell:summon("armor_stand", { Tags = { "marker" } })
spell:intercept("SpellFinishedEvent", function(evt)
  if evt.spell == spell then
    spell:executeSilent("/kill @e[tag=marker]")
  end
end)
while true do
  sleep(20)
end

Fields

name: string — Read-Only

The name of this event.

spell: Spell — Read-Only

The spell that has ended.