This was brought to me earlier today, and I’ve come up dry. Here’s the example.
A player is in a world, lets call it mining. He logs out while still in that world. For whatever reason, admin unloads said world. Later on the player logs back in. This is where things get interesting. The server will create a new world named “Overworld” and spawn said player in that world. Once this happens the only way to get rid of this world is to shut down the server and manually delete it. I can’t figure out how to handle this. I thought ClientConnectionEvent.Login would be able to handle sending the player to a different world if the last known is not loaded, but it doesn’t fire until after the damage is done. Thoughts?
The idea here is you don’t want the world to load. and like I said before the only event to track this behavior is ClientConnectionEvent.Login which fires after the things go wrong. And what about if that world is deleted? Same issue. The idea is the player should spawn in the default world or my choosing. That doesn’t even cover the real issue, which is why wouldn’t Sponge automatically load the unloaded world, instead of creating a new messed up world that you can’t even unload or get rid of without shutting down the server?
Okay so you need a way to spawn them in the default world if the one they logged out in is unloaded and ClientConnectionEvent.Login handles that to late.
What do you think would happen if you tried handling it within the authentication part of the connection process? I think that is before login. i.e. ClientConnectionEvent.Auth might need some error handling for failed auth and other errors but i think that might be able to help you.
I had a similair problem: Players with logout position in a disabled/deleted world?
Apparently a player without valid spawn-pos always gest transported in the main-overworld … so if your server.properies say: level-name = world your server searches the overworld “world”.
I also noticed that if one of the standard dimensions (Overworld, Nether, The End (or world, DIM-1, DIM1)) is disabled via config, and a player wants to go there via portal or in your situation, Sponge or Forge automatically creates a new world called “Overworld”, “Nether” or “The End” and sends your player there. I don’t know if this is intended behavior (i think not ^^).
(Also if you disable one of those generated worlds as well, the server crashes)
Maybe Sponges Dimension-Dev should take a look at this? ^^
That was my thought too but as @Blue said there’s no location data. I think I might put something on git and see if any of the dev’s bite on the topic.
I got round this issue. I teleported the player to a world that i knew was going to be loaded all the time, as in ‘spawn’ on player quit event. I also recorded the location they were at before the teleport.
On player join event i teleported back to the recorded location if it is there. I know this may not be exactly what you need but still. May give you inspiration