Solved Checking if a config exists?

Discussion in 'Plugin Development' started by isleepzzz, May 23, 2014.

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

    isleepzzz

    Hello there!
    So, I have my default config like this:
    Code:
    userdata:
      iSleepzZz:
        miningLevel: 1
        miningXp: 0
        woodcuttingLevel: 1
        woodcuttingXp: 0
    Now, I can simply change the numbers of Xp and Levels however what I need to know how to do is two things:
    - Create a userdata.THEIRNAME if the player doesn't already exist in the config
    - Add the
    Code:
        miningLevel: 1
        miningXp: 0
        woodcuttingLevel: 1
        woodcuttingXp: 0
    under their userdata.THEIRNAME so they can start from fresh since it is their first time playing.

    Can someone help me accomplish this please?:/
     
  2. Offline

    Adriani6

    isleepzzz

    You could do something simpler, create per player config files :)

    Also, use UUIDs to store stuff about players.
     
  3. Offline

    isleepzzz


    That actually would be a lot more organized and I would love that:)
    However I am unaware of how to accomplish making a .yml file for each player who joins :/
    If you could help, that would be lovely.
     
  4. Offline

    rsod

    isleepzzz
    http://pastebin.com/Wa4A0h0Q
    Usage:
    Code:
    CustomConfig variable = new CustomConfig("dir", "filename", this); //will put filename.yml in "dir" subfolder of your plugin
    CustomConfig variable2 = new CustomConfig(null, "other_filename", this); //will put filename.yml in the root of plugin directory
    variable.get(); //returns FileConfiguration
    variable.get().getString(...); variable.get.set(..., ...); //etc
    variable.save(); //don't forget to save
    ...
    variable.reload(); //or reload if you want to re-read it
     
  5. Offline

    isleepzzz


    I don't see how that helps me?
    All I need to know how to do is write some lines in my config file.
    Not create basically the exactly same thing but another config file.
     
    Adriani6 likes this.
  6. Offline

    rsod

    isleepzzz eh?
    getConfig().set("path.to.line", "any-data");
     
  7. Offline

    Adriani6

Thread Status:
Not open for further replies.

Share This Page