Solved Simple Config I can't figure out

Discussion in 'Plugin Development' started by Fhbgsdhkfbl, Aug 1, 2014.

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

    Fhbgsdhkfbl

    Hey bukkit forums, I currently started working with configs and such, and I sort of figured it out, but now I'm having a problem, I changed something in my config, then it reloads and goes back to the default config, and I don't know why

    onEnable and onDisable
    Code:java
    1. public void onEnable() {
    2. if (!setupEconomy() ) {
    3. getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
    4. getServer().getPluginManager().disablePlugin(this);
    5.  
    6. return;
    7. }
    8. getConfig().options().copyDefaults(true);
    9. saveConfig();
    10. registercommands();
    11. getServer().getPluginManager().registerEvents(this, this);
    12. PluginManager pm = Bukkit.getPluginManager();
    13. pm.registerEvents(new KitEvents(this), this);
    14. pm.registerEvents(new NoDrop(), this);
    15. pm.registerEvents(new Killstreak(this), this);
    16. pm.registerEvents(new Spectate(this), this);
    17. pm.registerEvents(new KitSigns(this), this);
    18. pm.registerEvents(new GUIListener(this), this);
    19. }
    20.  
    21. public void onDisable() {
    22. saveConfig();
    23. }


    Config:
    Code:java
    1. # Skyward Configuration files
    2. kitmessage: You have recieved the


    It may be simple for other people, but not for me :/
     
  2. Offline

    ZodiacTheories

    Fhbgsdhkfbl

    onEnable():

    Code:java
    1. getConfig().options().copyDefaults(true);
    2. saveConfig();
     
  3. Offline

    Stealth2800

    Try replacing 'getConfig().options().copyDefaults(true);' with 'getConfig().options().copyDefaults(false);'
     
  4. Offline

    Fhbgsdhkfbl

  5. Offline

    McMhz

    Fhbgsdhkfbl
    --
    Try removing the
    "saveConfig();" from the onDisable.

    That may solve the problem, but I haven't worked on yaml for a long time so don't count on it.

    Edit: I did this on one of my plugins and that worked (then)
    Ps: I couldn't edit it via the "edit" button since my browser doesn't let me for some mysterious reason.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
    Fhbgsdhkfbl and Stealth2800 like this.
  6. Offline

    Fhbgsdhkfbl

    McMhz
    Wow, that did fix it...
    Thank you, I appreciate it.
     
    McMhz likes this.
  7. Offline

    McMhz

    No problem, I had this issue semi-recently on one of my plugins.
    I'm glad to help, If you have any other issues you can tag (or) pm me and I'll see what I can do.
     
  8. Offline

    Giraffeknee

    Fhbgsdhkfbl
    I use saveDefaultConfig() in my onEnable() and use saveConfig() in my onDisable(), make sure you're saving the file in your IDE with whatever you want inside of it (if you're using an IDE).
     
  9. Offline

    Fhbgsdhkfbl

  10. Offline

    Giraffeknee

    Are you using eclipse?
     
  11. Offline

    Stealth2800

  12. Offline

    Fhbgsdhkfbl

Thread Status:
Not open for further replies.

Share This Page