Storage Methods?

Discussion in 'Plugin Development' started by Zach_1919, May 30, 2013.

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

    Zach_1919

    So I am debating about which storage methods I should be using in my plugins. I could use HashMaps or MetaData, however neither one is persistent. I've heard the only way to persistently store things is by creating a file and loading it in onEnable(), although I was wondering if there are any other persistent methods of storage. If not, then how do I create and call on files? I've always been wondering this.
     
  2. Offline

    recon88 Retired Staff

    For persistence, just store it in SQL and restore it at startup.
     
  3. Offline

    Technius

    Zach_1919
    You have several methods:
    1. SQL - SQL is fast, but it may not be available to all servers.
    2. YAML - YAML comes with Bukkit, but is somewhat limited.
    3. Java's libraries - These come with Java and can be used for any kind of data imaginable.
     
  4. Offline

    AmShaegar

    What about LiteSQL? It's offline so not limited by server restrictions.
     
  5. Offline

    Zach_1919

    AmShaegar Technius Well I have heard of SQL, but I'm not that familiar with it, and I do not know much about YAML, but I assumed it would be limited. How can I store in the Java Libraries?
     
  6. Offline

    AmShaegar

    I guess he meant basic IO like FileWriter/-Reader etc.

    To sum it all up: You want to save data but you do not know any IO basics. I guess you should read some tutorials.
     
    recon88 likes this.
  7. Offline

    Firefly

    YAML and the config API is easy to pickup for beginners, especially if you need to store a few booleans, strings, integers, etc.

    Also, what limitations are you thinking of when it comes to YAML? Technius.
     
  8. Offline

    Zach_1919

    AmShaegar Yeah, I know, I hate to be that noob that comes on the forums without doing any searching, I'm sorry. I didn't realize it at first :p
     
    AmShaegar and recon88 like this.
  9. Offline

    Technius

    Firefly
    Some data, such as world files, will have large sizes when stored with YAML. It is also difficult to insert comments into YAML using code. I can't think of the other limitations right now.

    Zach_1919
    The Java tutorials for IO can be found here. If you don't want to use the Java libraries, you can find a YAML tutorial here.
     
  10. Offline

    Zach_1919

    Technius Yay :} Thank you sooo much

    EDIT: The only thing is, how do I create a new file and call on that file, not using Bukkit methods. Bukkit methods only look for config.yml. Is there some way that I can call on a specific yaml?
     
  11. Offline

    AmShaegar

    Code:
    public void reloadMessageConfig() {
            messagesfile = new File(plugin.getDataFolder(), "messages.yml");
            messageconfig = YamlConfiguration.loadConfiguration(messagesfile);
        }
     
  12. Offline

    MoonStorm

    Yeah, plus you'll get countless questions from players asking why their plugin config fails to load. A tiny space here, a tab somewhere else, and you get sections instead of setting values. Any config file format that relies on indentation is a piece of <bleep>. :mad:
     
    microgeek likes this.
  13. Offline

    Firefly

    Meh, they are perfectly suitable for my needs. Custom objects can be easily saved to the config API and I don't have to fiddle with I/O. Plus, server admins have become accustomed to using the YAML format: so using it whenever you can is a good idea.
     
  14. Offline

    MoonStorm

    Yep, this entire world is filled with server admins, and they all use proper tools for modifying them, definitely not Notepad.
     
Thread Status:
Not open for further replies.

Share This Page