Using PlayerLoginEvent instead of PlayerJoinEvent for loading data

Discussion in 'Development' started by Levi, Mar 20, 2019.

  1. Levi

    Levi Zombie Pigman

    Messages:
    764
    GitHub:
    captainleviftw
    I plan on loading players' data into an array when they join. Should I do this on PlayerLoginEvent or PlayerJoinEvent
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,847
    GitHub:
    sof3
    It depends when you need to use the data.
    Generally speaking, load your data asynchronously in login event.
     
  3. Levi

    Levi Zombie Pigman

    Messages:
    764
    GitHub:
    captainleviftw
    Ok. By asynchronously, I use libasyqnl to load the data into an array. Is that ok?
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,847
    GitHub:
    sof3
    Yes. But always check if the data are ready, because queries can easily throttle up when a lot of players join simultaneously. However this depends on your number of worker threads and actual connection speed. If you have 40 players joining simultaneously when the server starts, and each query takes 500ms to return, and you set 4 worker threads, you theoretically need 5 seconds to complete all queries (more if you have multiple queries per player). However, considering the slow connection speed of the client, this might not cause issues as dire as it sounds.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.