Best way to save data

Discussion in 'Plugin Development' started by mineshafter2202, Sep 16, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    mineshafter2202

    I've been working on a plugin for a friend, and I have come across an issue: What's the best way to save data for this? The plugin adds skills, which means I need to keep track of quite a few things like what classes they chose and what skills they have upgraded. Which type of file would be better for this, MySQL, YAML, or another file type?
    EDIT: For MySQL, I was thinking about using SQLibrary (on BukkitDev)
     
  2. Offline

    Da_Co0k1eZ

    I would use MySQL if you can, but if you can't SQLite is always an option.
    Edit: Both of these methods are easily accessible with the SQL plugin.
     
  3. Offline

    mineshafter2202

    Thanks, I'll see if it works out with the plugin!
     
  4. Offline

    Skionz

    mineshafter2202 Definitely MySQL. Personally I don't like having too many dependencies so I would just use JDBC. If you don't know anything about it I can send you a few methods I wrote for creating a cross-server economy and I can add a bunch of comments :D
     
  5. Offline

    Valtureyn

    Use the serializable.
     
  6. Offline

    mineshafter2202

    Skionz I really don't know much about MySQL, so that would really help!
     
  7. Offline

    fireblast709

    Da_Co0k1eZ Skionz Why would you use MySQL over simple, flatfile YAML. Please elaborate.
    mineshafter2202 YAML file per player would be my choice in this case.
     
  8. Offline

    Skionz

    fireblast709 Usually the database is free space when using a host and this is just me but a while ago I guess I used /reload a few to many times and it reset all the YAML files (might be hosts fault). Also I like browsing peoples data and stalking how many kills / deaths they have. But that's just me :p
     
  9. Offline

    Da_Co0k1eZ

    fireblast709 Using a YAML flat file would be stupid when dealing with large amounts of data, such as that of every player that joins a server. MySQL and SQLite are both compiled into there own separate data types, and therefore are much faster when wrote and read when dealing with large amounts of data.
     
  10. Offline

    fireblast709

    Aside that you don't make much sense in the first part, you are absolutely wrong in the second. File I/O tends to be much faster than a remote connection (regarding MySQL). YAML has superiority over SQLite in two points:
    • In terms of memory usage (you could load per-player files and unload them when no longer needed, while SQLite needs to load the whole file)
    • In terms of concurrency, you can write files concurrently but SQLite does not allow this (only concurrent reading with some database fine tuning)
    • Since YAML already is direct access once loaded, you cannot outperform it with SQLite and caching. At most equal performance can be acquired.
     
  11. Offline

    xTrollxDudex

    MySQL is almost a language on its own, if you need it to be fast and orderly, flat file should do fine. MySQL is a database, for keeping large amounts of lists and associated data together, which is achieved in an easier way using flat file.
     
  12. Offline

    mineshafter2202

  13. Offline

    fireblast709

    mineshafter2202 Just use YAML for the ease of it. I see no reason to use SQL in this case.
     
  14. Offline

    mineshafter2202

    fireblast709 Could you give an example for creating the file when the player joins?
     
  15. Offline

    xTrollxDudex

    Look at Java specifications please
     
  16. Offline

    Monkey_Swag

    mineshafter2202
    Create a playerjoinevent
    Check if the config contains the player's uuid
    If not set it in the config

    Simple as that
     
  17. Offline

    mineshafter2202

    I meant creating a separate yml for each player in another folder.
    But I figured it out, I'm using YamlConfiguration.
     
Thread Status:
Not open for further replies.

Share This Page