I have noticed a problem where people teleports to the default world spawn upon stopping the server, then joining back into it. This is really troubling me, because this makes LIAB (plugin by aliuly, multiworld inventory stuff) to load the inventory of the world in which the player was in upon stopping the server when they are in the main world. (ie lobby) So is it possible to create a hack to stop players to go to the default world? I thought about teleporting players upon joining, but PlayerQuitEvent cannot be detected on server stop because plugins unload first.
Plugins are not necessarily enabled when server starts and disabled when server stops. Plugins can be enabled or disabled at the middle of the server runtime. Therefore, always expect there to be players online and not kicked when plugin enables or disables. Just iterate over online players and handle them one by one on plugin disable.
But doesn't plugin disable means that the plugin will have no effect on the server because it is, well, disabled? Or is there an event or a way to detect when /stop is executed but right before plugin disables? If this is the way you mean, how should I handle crash?
Wait, the reason why people spawned in the default world was just because it wasn't loaded?! EDIT: TYTY IT NOW WORKS
For crash: you can't handle it, the whole process crashed, and you are lucky you can still recover things like files and free the server port. Crash means termination of everything - you shouldn't be able to handle it, or you will have a high chance of "crashed while crashing". For disabling: you don't need to know when the plugin is disabled. Just always assume that the server doesn't stop when your plugin disables, and server has started for a long time and players are already on the server when your plugin enables. This is what plugins should do.