Need creature_despawn event hook...
LadyCailin opened this issue ยท 1 comments
CMDHELPER-2633 - Reported by surfarcher on 2013-04-09 04:12:39 UTC
A creature_spawn hook was added in CH 3.3.1 however no complementary creature_despawn was added.
One can code hold data in an array in creature_spawn and then removing those values when a creature dies. However many creatures despawn without dying. This leaves the assign value sin memory, simply accumulating over time. A little like a memory leak.
Current workaround is to use a timer and check that all stored entities are valid, removing those that are not.
It would be more resource efficient for this to be handled in a creature_despawn event or similar.
Comment by PseudoKnight on 2018-03-31 07:08:59 UTC
(Cleaning up some old requests)
So there's no catch-all event for cleaning up entity references in the Bukkit or Spigot API, unfortunately. Entities can despawn (no event), be unloaded with a chunk (ChunkUnloadEvent), or even removed by a plugin (no event). So it seems garbage collection, as you mentioned, is the only complete solution if a script must do this.
There is an EntityRemoveFromWorldEvent in the Paper API that looks like it might offer a complete solution, but that would need to be added to the CHPaper extension.