[SPIGOT-336] EntityDespawnEvent Created: 01/Jan/15 Updated: 21/Feb/24 Resolved: 21/Feb/24 |
|
| Status: | Resolved |
| Project: | Spigot |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor |
| Reporter: | Morphan1 | Assignee: | Unassigned |
| Resolution: | Fixed | Votes: | 9 |
| Labels: | chunks, death, entity, event, metadata, removal, unload | ||
| Issue Links: |
|
||||||||
| Description |
|
Currently in Spigot, there is no way to listen for when entities despawn. It would be extremely useful for allowing plugins to store non-metadata information that gets removed when the entity is despawned. |
| Comments |
| Comment by RyanTheLeach [ 06/Feb/22 ] |
|
It would probably still be useful to be able to track entity lifetimes and when they are removed/killed for any reason.
But I believe that the Persistent Data Container provides API to attach data to an entity that persists as long as the entity does (for anyone that stumbles into this issue). https://hub.spigotmc.org/javadocs/spigot/org/bukkit/persistence/PersistentDataContainer.html |
| Comment by Morphan1 [ 26/Apr/19 ] |
|
The workaround mentioned above is no longer possible, as 1.14 has removed IWorldAccess. Our use case suffers from this: we require a system that attaches data to an entity which is preserved over restarts through a data file. This is not currently possible to sanely accomplish without said data file being polluted with entities that are long gone, as there is currently no way to listen for when they've been fully removed. |
| Comment by Morphan1 [ 16/May/15 ] |
|
For anyone interested, this is possible via a workaround with NMS using a class like: |
| Comment by Morphan1 [ 25/Jan/15 ] |
|
For an example, how about... Any information that needs to be saved across restarts? |
| Comment by Llm Dl [ 15/Jan/15 ] |
|
Personally, I'd use it in a plugin I have where one entity is riding another. One of them is considered 'hostile' and is removed from some regions/towns. I would like to make the entity riding that entity also disappear along with the riden entity. |
| Comment by Ryan Hamshire [ 15/Jan/15 ] |
|
Will you please provide an example of a piece of information which you'd want to delete when an entity despawns, but couldn't or wouldn't want to store using the metadata API? |