Best Data storage solution for Player Rank and Level?

Discussion in 'Plugin Development' started by Munnzeh, Jul 26, 2020.

  1. Offline

    Munnzeh

    Hi All,

    I am looking for suggestions on the best solution to storing Player Rank and Levels, I have done some research and the obvious solution is SQL. However I wanted to get some answers related to my specific use case and whether there are easier ways to do it.

    What I would like to do is to store a Players Rank, and a Players Level, so it can be used in ChatEvents [Level] [Rank] Player-Name and it can also be used in assigning Points to a player.

    My concern is that making a call to whatever storage / database I use, every time a player talks in chat seems cumbersome, is there an easier solution? As I imagine querying the database for the players level and the players rank on an AsyncChatEvent is going to cause some chat delay. The same goes for assigning points.

    Could I for example query the database once and store the users Level / Points and Rank in a Hashmap / List when they join and update it with any changes when they leave? Keep in mind the intention for the server is to have around 40 - 60 players online.
     
  2. Offline

    Visualizeding

    Why would you query the database every time? All you have to do is query it once on player join, and store that data in an object like a User object or something. You can keep a list / map of the user objects and use the data queried whenever needed such as rank, balance, etc. In fact you can also query the database for every user on server startup without the need to do it on join if you want.
     
  3. Offline

    Munnzeh

    Great idea, really appreciate the suggestion. One question, (if I understand you correctly) if I were to query the database for every user in the database on startup and create a User object for each one, wouldn't that be a bit intensive if let's say the database contained 500 players? Wouldn't on join be more efficient or no?

    Would you recommend MySQL for this use case?
     
  4. Offline

    KarimAKL

    @Munnzeh I'd probably go for a loop of the online players onEnable (in case someone is online while the server is reloaded (not restarted)) and then a listen to onJoin for the players that'll join later.

    I'm no expert at this subject but, i believe MySQL should be fine.
     

Share This Page