Unloaded worlds, offline players

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?

1 Like

Just load all previous worlds? I would think that would handle any unloaded worlds.

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?

Yes. Seems to me like an oversight. Again, if the world has been unloaded or deleted, It should default to the default world at least.

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.

Exactly, which is why it should be handled by Sponge internally. Unless I’m missing something

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.

Auth doesn’t have the necessary methods, such as getFromTransform() and getToTransform(), unless I can figure out a way to make GameProfile useful

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? ^^

3 Likes

Think theres a way to get a user from a GameProfile, that might help you.

User has no Location data … i don’t know why, but there is no way to know where a player will spawn, when he’s offline …

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.

1 Like

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 :wink:

Has anyone reported this on SpongeCommon or some other repo yet?
If yes: Care to post a link?
If not: Why not? :wink:

I believe this actually is a Sponge related issue.

Reported on SpongeCommon:

1 Like

There should be a default world, where players get spawned or teleported to.