What is the most appropriate way to manage data?

Discussion in 'Spigot Plugin Development' started by bobbutts, Jul 3, 2018.

  1. Hello!

    I'm writing a plugin that tracks the number of times a player hits a button. After they reach a certain number of presses, the plugin prevents them from pressing it anymore. Every 24 hours the server wipes the data, and the player can press the button again.

    What is the most appropriate way to store data like this? Currently i just write a new file for each player who pushes the button, then i keep track of how many button presses they have in that file. After 24 hours, the file is deleted. Bad practice or no?
  2. In your case I'd use a SQL database, sqlite already comes in your spigot jar. If you find the queries are too slow ( You'll just have to test this and see) then keep an in memory cache and dump that state to your database periodically.
  3. Thanks! But why do you think that?
  4. It's a fairly simple way to save your data in one resource. You certainly don't have to do it this way, you could for example probably create a random access file format also, but that'd likely be a more complex problem for you. Creating a file for each player works but in my opinion is unnecessary.