What's Your Favorite Backend for Plugins?

Discussion in 'Plugin Development' started by Dino Filippini, Jun 14, 2012.

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

    Dino Filippini

    Greetings!

    I'm very familiar with java, but just recently began using the bukkit API, and am experimenting how to best create plugins that hold persistent information. If one was to store dynamic information about users, how would you recommend they store it for plugin use? Text files, databases, excel, etc.

    I know many different ways exist to accomplish this, but what's everyone's preference when it comes to Bukkit?

    Thanks much
     
  2. Offline

    theguynextdoor

    I am a massive fan of the bukkit yml configuration system for storing information due to it's ease of use on my behalf. For example getting a string from it is as simple as getConfig().getString("path"); Now you may say that using the config to store data is confusing for the user, but there are methods available which allow for you to have your own custom yml files which have the same functionality.

    People say that it is hard for the users/sever admins to set up, my answer to that is allow them to edit it ingame. An example of this is PEX which allows you to change different aspects of the permission groups in game (such as adding a permission to a group or even promoting someone).

    The only problem i can see is that it might not be the most memory efficient method when handling large amounts of data, but i can't confirm this due to me never having to store large amounts of data in a plugin. And if i was going to store large amounts, then i would look into MySQL which would make storing large amounts really useful without worrying about getting data being slow.

    The only problem i have with MySQL is that, for people like me who have never used it before, the syntax is not always easy to grasp. But there are many libraries out there which help you use MySQL.

    Text files are a nice way of storing data, but the only problem i find is getting the line you want, although this wont be a problem really because you can just add each line of the text file to an array list when the plugin loads up and then save it when the plugin disables.
     
  3. Offline

    desht

    theguynextdoor agree completely - the Bukkit Configuration API is great for simple persistence (i.e. storing a few strings, integers, even a few objects). It's also well worth learning the ConfigurationSerializable functionality - you can make your classes serializable very easily with this. E.g. here's a PersistableLocation class which can be serialized to a file simply by saying:
    PHP:
      config.set("location", new PersistableLocation(player.getLocation()));
      
    config.save("persisted.yml");
      
    // somewhere else in the plugin...
      
    PersistableLocation pl = (PersistableLocation)config.get("location");
      
    player.teleport(pl.getLocation());
    For heavy-duty persistence - storing hundreds or thousands of records and/or making many store/retrieve calls a second, a database is indeed the way to go - SQLite or MySQL being the obvious choices. MySQL takes more setup of course, but will perform better. It may be overkill for most things, though.

    Writing stuff to plain text files is OK for one-off storage (i.e. loading once at plugin startup) but I really wouldn't suggest it for data that needs to be stored/retrieved on a regular basis during the plugin's lifetime. That's just asking for server lag.
     
    Mitsugaru likes this.
Thread Status:
Not open for further replies.

Share This Page