As the title self described, how to handle server /reload properly by reloading configs and so on...? i dont seem to find onReload function or any related event listeners? i remember sofe mentioning how some developers did a poor implementation or something related to reload so it is better to restart, and since this section is added so i might as well ask it here I guess i should do a Xpost to dev section as if this section is as good as posting on pocketmine.net
Reloading unloads the plugin normally. You should just free all references to everything else on unload, destroy all tasks, destroy all your objects (and save your data beforhand). then you are very likely to not run into problems, because the reload just acts like a normal plugin unload and then loading it again.
no, to free all references and save data. unsetting everything will also help. Most important is destroying your objects. (unset/free all references to them)
During the reload phase, the server doesn't stop. The plugin run through its onDisable function where it's supposed to destroy all objects and save any data needed to the config or a database.
Reloading is to unload the plugin and then load it again. Most things will be automatically reset, and iirc the plugin instance is also garbaged (a new one will be instantiated), so you don't need to unset anything explicitly. However the Server instance isn't reloaded. Basically, if you don't use any static class properties, and if you don't register anything to the Server that isn't disabled by plugin unload (basically, anything you register other than event handlers, commands and plugin tasks), you don't have to worry about it. Sorry I think I wrote something wrong in the other post - most plugins support server reload, just that merely using the reloadConfig() function doesn't reload the config data known by the plugin.
Do Async tasks get destroyed automatically? EDIT: For example asnyc tasks don't get destroyed or stopped. they will suddenly callback onto your old plugin instance [If you used the server object to store your instance], or try to get your plugin instance from the PluginManager, which will crash the server. Reference https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/scheduler/ServerScheduler.php#L236 only PluginTasks get stopped. (no asynctasks)