Help saving values to Config.yml!

Discussion in 'Plugin Development' started by Gabum, Mar 24, 2014.

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

    Gabum

    Hello guys!
    I'm a bit more experienced Java Programmer, and currently messing around with Plugin ideas.
    The most of them need to save values, so I thought about saving them to a config.yml .
    For example, I want to save the score (an Integer value, which is handled and managed by the plugin) of all players that joined the server so far.

    But how do I do this? I understood most of the things in the API, but I don't really know how and when to use saveConfig(), saveDefaultConfig(), reloadConfig(), and which file JavaPlugin.getConfig() returns, the file in the data folder, or the one in the jar?

    Thanks for your help!
     
  2. Offline

    Botifier

    save config should work.

    this might help; its from stuntguy3000 and coastermans10's annihilation plugin
    Code:java
    1. public void setValue(StatType s, Player p, int value) {
    2. if (!plugin.useMysql) {
    3. config.getConfig("stats.yml").set(p.getName() + "." + s.name(),
    4. value);
    5. config.save("stats.yml");
    6. } else {
    7. plugin.getDatabaseHandler().query(
    8. "UPDATE `" + plugin.mysqlName + "` SET `" + s.name().toLowerCase()
    9. + "`='" + value + "' WHERE `username`='"
    10. + p.getName() + "';");
    11. }
    12. }
     
  3. Offline

    Mattkx4

    I have a pretty extensive post on this page. If you need anymore help just ask and I'll help you at.
     
Thread Status:
Not open for further replies.

Share This Page