Keep player in loading screen

Discussion in 'Spigot Plugin Development' started by sander_blaadjes, Jun 5, 2016.

  1. Hello there,

    I am wondering if it is possible to keep the player in the loading screen for a little longer, here is why:
    If the player logs in, he will have to be teleported to a location different to where he logged off. I want the player's location to be set to this new location so he doesn't notice being teleported and joins when the chunks are loaded. (Your join screen will only disappear once your client has received sufficient chunks to spawn you without of you falling through the world, this is a feature built into minecraft.)
    However, I am getting the location where the player needs to be teleported to from a database (Async). Any ideas on how I can get this done? I don't want to load the player's data in the main loop because it will freeze up everything.
     
  2. I'm not sure, but try PlayerPreJoinEvent and there you teleport him to the desired location.
     
  3. https://www.spigotmc.org/threads/so...ent-to-open-loading-screen.48844/#post-552210
     
  4. It might be a little bit hacky, but in the AsyncPlayerPreLoginEvent, you could perform a Thread.sleep() as the event is called on a thread that is unique to the client. Make sure to not execute code on that same thread if you're gonna do it.

    Or do what le person above me said, although it is not version-stable. ProtocolLib could work tho
     
  5. This does seem like a more suitable solution for my needs, I'll try your solution. ;-)
     
  6. Or you could just execute the DB operations on the same thread as the event is called on, avoiding unnecessary Thread creation.
     
    • Winner Winner x 1