Config not working.

Discussion in 'Plugin Development' started by Connor2weirdness, Mar 12, 2014.

Thread Status:
Not open for further replies.
  1. I'm using:
    Code:
    this.getConfig().addDefault("cooldown", "10");
    this.getConfig().options().copyDefaults(true);
    this.saveConfig();
    int time = this.getConfig().getInt("cooldown");
    
    It's returning "0". Thanks.
     
  2. Offline

    Heirteir

    Connor2weirdness
    instead of doing that change it to
    Code:java
    1. this.getConfig().set("cooldown", 10); //Set the value instead of adding a default much for stable and //easy to use in a java plugin
    2. this.copyDefaultConfig(); //Use this instead of the other one your using this one also renders comments in the file // and is less glitchy
    3. this.saveConfig(); //saves the config as usual
    4. int time = this.getConfig().getInt("cooldown");


    Hope i helped!

    Also don't put "10" put 10 if you want an integer that will return a null error.
     
  3. Thanks but it still returns "0".
     
  4. Offline

    Heirteir

    Connor2weirdness
    delete "this.copyDefaultConfig();" and if that doesn't work please post your whole code so i can see what's up
     
  5. EDIT: Thanks guys! I had to delete the config and reload it.
     
Thread Status:
Not open for further replies.

Share This Page