Any idea on how to do that?
#4
The chunks are only queued for unloading, because otherwise plugins would cause a lot of deadlocks (a plugin waiting for unloading chunks in one world, while the world is waiting for that same plugin to provide a callback value in its tick thread).

There is no way to know that the chunk unloading caused by the QueueUnloadUnusedChunks() has finished, but there are some workarounds. You can use the HOOK_UNLOADING_CHUNK to keep track of when the last chunk was unloaded, if it was more than N ticks ago (consider N = 5, for example), you can assume that the unloading has finished for that world; once it has finished for all worlds, you can send the stats.

FakeTruth's solution with waiting just one tick isn't sufficient - chunk unloading is asynchronous, it may take several ticks to unload a chunk, and each world ticks in a different thread anyway, which is yet different from the server tick thread.

To complicate matters even more, the SaveAllChunks() doesn't actually wait for the chunks to be saved, it queues a save action, so most chunks won't unload anyway, because they won't be saved yet. Therefore I dare say any plugin trying to do chunk maintenance is destined to fail.
Reply
Thanks given by:


Messages In This Thread
Any idea on how to do that? - by tonibm19 - 03-10-2014, 04:31 AM
RE: Any idea on how to do that? - by FakeTruth - 03-10-2014, 04:54 AM
RE: Any idea on how to do that? - by worktycho - 03-10-2014, 05:01 AM
RE: Any idea on how to do that? - by xoft - 03-10-2014, 05:08 AM
RE: Any idea on how to do that? - by worktycho - 03-10-2014, 05:12 AM
RE: Any idea on how to do that? - by xoft - 03-10-2014, 06:48 AM
RE: Any idea on how to do that? - by worktycho - 03-10-2014, 06:55 AM
RE: Any idea on how to do that? - by xoft - 03-10-2014, 07:02 AM
RE: Any idea on how to do that? - by tonibm19 - 03-11-2014, 02:21 AM



Users browsing this thread: 7 Guest(s)