I’m currently working on a Waterfall Plugin
supposed to log players’ statistics in a MySQL Database. (see Attachment).
First of all, my concept of the plugin:
I work with HikariCP and execute the queries asynchronously.
As you can see in the attachment I’m going to store the UUID, the Name, the Registered Date, the LastLogin Date, the OnlineTime, and the number of sessions. A player’s statistics should be visible to team members with a certain command at any time.
The online time of a player should be in the scoreboard and updated (I will probably use the PluginMessage Chanel in order to transfer the online time from the bungee to the paper
My thoughts on achieving it:
When a player connects itself to the proxy I will check if the player exists in the database. If it doesn’t exits I will insert the current date for the registered date and the lastLogin, its UUID, its NAME, its OnlineTime (0) and its sessions (0). For the online time I will save the loginTime and the quitTime in an HashMap and calculate the session’s online Time at the leftEvent.
So now my question:
How would you achieve this plugin?
Should I use a player Object in order to handle the players statistics?
How can I achieve the online time thing? (I can’t always send a request to the database when the scoreboard is updated. (Performance))
When would you write the online time in the database? On the Left Event?
Should I work with a cache? (Store all player objects in a HashMap)
A big thank you in advance for every answer and suggestion.