Solved Adding new sections to the config.

Discussion in 'Plugin Development' started by TopTobster5, Feb 22, 2014.

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

    TopTobster5

    Hi. I'm trying to save some player data to the config. This includes their name, kills and other stuff. This is in the format of:
    Code:
    TopTobster5:
        kills: 5
        deaths: 2
    SomeOtherGuy:
        kills: 7
        deaths: 16
    However, when someone new joins the server, I need to add their information to the config. How do I do this?
     
  2. Offline

    minecraft124_

    In your PlayerJoinEvent, you can call the FileConfiguration.createSection(String) method to create a new section in the config.
     
    TopTobster5 likes this.
  3. Offline

    TopTobster5

    minecraft124_ How would I add the sub parts? (The kills and deaths parts)
     
  4. Offline

    minecraft124_

    Code:java
    1. config.createSection(playerName + ".kills");
    2. config.createSection(playerName + ".deaths");

    should be put in your PlayerJoinEvent class. You should also check if the player is already in the config using
    Code:java
    1. if(config.contains(playerName) {
    2. ...
    3. }
     
    TopTobster5 likes this.
  5. Offline

    TopTobster5

  6. Offline

    mazentheamazin

Thread Status:
Not open for further replies.

Share This Page