Solved new config file

Discussion in 'Plugin Development' started by stamline, Apr 22, 2014.

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

    stamline

    How can I make a second config file?

    I looked on other posting but they was not good for me....

    and I need to get the config from other classes
     
  2. You cant, you can make a new YML file though:

    Code:java
    1. File config2;
    2. FileConfiguration getConfig2;


    then under onEnable() {
    Code:java
    1. config2 = new File(getDataFolder().toString() + "/config2.yml");
    2. try {
    3. config2.createNewFile();
    4. } catch (IOException e) {
    5. e.printStackTrace();
    6. }
    7. getConfig2 = YamlConfiguration.loadConfiguration(config2);

    }

    To Retrieve data use getConfig2.get .....
    To Set data use getCon fig2.set
    AFTER YOU SET SOMETHING ALWAYS DO
    Code:java
    1. try {
    2. getConfig2.save(config2);
    3. } catch (SomeExceptionIdkItOffTheTopOfMyHeadException e) {
    4. e.printStackTrace();
    5. }
     
  3. Offline

    stamline

    Thanks, this really helped me, Thanks again :D :D
     
  4. No problem
     
  5. Offline

    stamline

    This doesn´t work.... getConfig2.get and getConfig2.set
     
  6. Joiner
    You only need getDouble()/getInt()/getString() ect for Getting, not setting
    stamline
    Read above and this to be able to get/set things to it
     
  7. Offline

    stamline

  8. int time = getConfig2.getInt("time");
    getConfig2.set("time", time +1);
    try {
    getConfig2.save(config2);
    }catch(Some error e){
    e.printStackTrace();
    }
     
  9. its
    getMines.set(arg0, arg1)
    Not setDouble/Whatever
    Only .set
     
  10. Offline

    Deleted user

    As WD_MUFFINFLUFFER said, you must surround with Try . . . Catch.
     
  11. Offline

    stamline

    Okey, thanks, it worked now.... I change something in the code so i couldn´t use getInt....
    THANKS :D
     
  12. stamline
    No prob, please set this to Solved if everythings working :)
     
Thread Status:
Not open for further replies.

Share This Page