Storing balances!

Discussion in 'Spigot Plugin Development' started by Viazo, Feb 12, 2018.

  1. Ok I am attempting at making a custom plugin ecosystem for a server I might make, I already have all the methods, API, and events setup for my economy plugin the thing I'm waiting for is How would I go about storing them(Don't say SQL database) what would be the best and most efficient way to store these balances locally?
    #1 Viazo, Feb 12, 2018
    Last edited: Feb 12, 2018
  2. Most efficient: MySQL database...
    Another option: YMAL files...
    Least efficient (in my book): JSON files
  3. Obviously the best way is MySQL, but also YAML isn't a bad idea. In this way you can edit player balances with FTP too.
    • Agree Agree x 1
  4. Storing locally? Try looking into a SQLite database. It essentially is just a file, like a YAML file, but acts as a small SQL database locally, so you don't need to run a MySQL database externally. As for your statement to not say SQL, I really don't see any reason why SQL isn't something you don't want as it is made for storing things: a database.

    Nevertheless, here is another option. You can use a REST API that you can send data to, which runs on php, node.js, Spring Boot, whatever you want. However, the underlaying data structure will probably still be SQL.

    EDIT: I would however strongly advise to NOT use a YAML file to store something like economy information. If a lot of read/write operations are executed on a single file, it can turn into a disaster if you don't properly deal with data being read and accessed at the same time, or create glitches caused due to data being out of sync. Most SQL databases do everything in transactions, rendering it quite difficult to get data to be out of sync when used properly.
    • Like Like x 1
  5. As McJeffr already said, SQLite would be the best method here.
  6. What I meant was no SQL External Databases I wanted a local file, I will be looking into SQL lite! Thanks for telling me the right local file.
  7. Why no ‘external databases’ they’re the best option for something like this?
    • Agree Agree x 1
  8. Because If I start this I want to start off small. Not a external database since It will not store tons of information! + I will upgrade to MySQL when I decide it is the right time.
    • Optimistic Optimistic x 1
  9. It is reasonable to start with SQLite, especially if you need to store data of only one server and don't need to hook into SQL from another server or service. There are slight differences between SQLite and MySQL when it comes to the datatypes, but in general migrating from SQLite to MySQL shouldn't be a problem. The other way around might be tricky because MySQL has a lot more datatypes, but they are all in the end capable of being stored in SQLite one way or another.

    Some fairly large plugins where databases are essential, such as PlotSquared (plugin that allows for creative plot building and more) uses SQLite by default, though has the ability to be hooked into an external database too because in the end they are pretty much similar.
  10. you can create a config file which will saves the playernames or uuids and their balance
  11. How is json least efficient? JSON doesn't rely on spacing and indentation, making it a ton faster to parse. You also have gson right at your hands (shaded into spigot). If you're a decent programmer, you'd notice that using gson/json allows for more availability and is just better to use in general for data storage.

    Now, for user-configuration, I'd use ymls.
  12. Least efficient in this case..YAML would just be easier... simply my opinion but I like YAML better than JSON.
    • Optimistic Optimistic x 1
  13. Easier does not mean more efficient. Resource-wise, json is a lot better.
  14. Its more efficient to code, again in my opinion, im not saying how quick it is, but for me its easier to code.
  15. Technically, YAML is a "JSON superset". This means that a YAML analyzer can include JSON but not necessarily the other way around.
    I recommend you to read these 2 sites: &

    In order to store data, it would be better to store them in a database rather than in flat-files.
    Databases can handle querying tasks, so you don't have to walk over files manually and it can update data easily and really faster than a flat-file.
  16. well uhh the following is valid yaml /shrug:
    Code (YAML):
    : "aaaaaa",
    : [
     "balances and stuff hehe"
    : {
    : "2^31-1"
    : "2^31"
    add support for SQL or Mongo, cause it'll be beneficial. SQLite is a great alternative which is 100% local by storing in a .db file, meanwhile JSON + a good directory structure is also a good alternative.
  17. If you're gonna use the ecosystem across the network (i.e a network wide point system) use MySQL or Mongo. However, if it's only for one server like factions, you're better off saving it in JSON files.
  18. How is this thread still active? Didn't the OP already stated he'd be investigating into SQLite and call it a day?

Share This Page