Glowkit-Legacy
Glowkit-Legacy copied to clipboard
Enhance & expose shutdown tracking
Here is a simple idea.
Various events may be thrown when the server shuts down but in other cases too, like PlayerQuitEvent
. onDisable()
can also be called when shutting down or when simply disabled for other reason.
That's why I suggest that there is a way to see is the server is currently shutting down.
It would for example allow to execute code synchronously instead of launching asynchronous tasks.
Examples:
- Saving player-related data in
PlayerQuitEvent
usually done by an async task, but the server may shutdown at that point and kill this task. - Saving config/files synchronously in
onDisable()
. Usually you don't need to do anything async here because the server shuts down, but it just slow downs the server if the plugin has actually been disabled dynamically. I'm not sure about that one, maybe the plugin is no longer able to do anything after it has been disabled.
It is not possible, or recommended, for the plugin to continue after disable.
So disabling a plugin will always have to kinda-lockup the server if it does any saving/heavy stuff
It should.
sent from mobile On Sep 10, 2014 10:36 AM, "Gael Ribes" [email protected] wrote:
So disabling a plugin will always have to kinda-lockup the server if it does any saving/heavy stuff
— Reply to this email directly or view it on GitHub https://github.com/GlowstoneMC/Glowkit/issues/6#issuecomment-55143442.
Plugin can use Thread.interrupted() or Thread.isInterrupted() to do stuff when it is being shutdown. (only works if ShutdownMonitorThread in Glowstone is changed to use Thread.interrupt instead of Thread.stop, and only if the plugin does not fully stop after GlowServer disables them)
So it might not be a good idea to add onDisable() because only plugins that are continuing a task will continue running after disable, and they should check if they are interrupted anyway.