Saving locations in .yml file

Discussion in 'Plugin Development' started by Iron_Crystal, Apr 15, 2012.

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

    Iron_Crystal

    Hey,

    I think this is fairly simple, yet I can't figure it out. This is what I need:

    When the player types in a command, it gets the target block's location, and saves it's x, y, z, and world values in the .yml file. When the player walks over the saved location, it does something.

    Any help? I've tried making for loops, but it can only loop through lists or arrays, and I'm stuck.

    Currently, my .yml file looks like this. It can be changed though.

    ChuteLocations:
    '1'
    x: 324
    y: 34
    z: 343
    '2'
    x: 334
    y: 36
    z: 345

    This seems like it should be simple, but for whatever reason I am blanking out on this.
     
  2. Offline

    Neodork

    I use this guys tutorial in combination with the information provided here

    save method
    Code:java
    1.  
    2. public void saveYamls() {
    3. try {
    4. config.save(configFile);
    5.  
    6. } catch (IOException e) {
    7. e.printStackTrace();
    8. this.getPluginLoader().disablePlugin(this);
    9. }
    10. }
    11.  



    set value's
    Code:java
    1.  
    2. config.set("Donator.x", dox);
    3. config.set("Donator.y", doy);
    4. config.set("Donator.z", doz);
    5. config.set("Donator.p", dop);
    6. config.set("Donator.r", dor);
    7.  


    Using your information you can make loops that look like:

    Code:java
    1.  
    2. private int getSome() {
    3. int count = 0;
    4. while(config.contains("something."+count)){
    5. count = count +1;
    6. }
    7. return count;
    8. }
    9.  


    with:

    Code:java
    1.  
    2.  
    3. length = getSome();
    4. for(int i =0; i<length; i++){
    5. config.get("Yourpath."+i);
    6. }
    7.  
     
  3. Offline

    Iron_Crystal

  4. Do you save it in the config.yml or a new file
    if it is a new file can you teach me how to make a new file
    thanks
     
  5. Offline

    Iron_Crystal

    To tell the truth, its currently in the config file, because I don't know either :p
     
  6. ow okay but thanks for your reply
     
  7. Offline

    Neodork

    plarsootje

    Meaning it is in the tutorial.
     
Thread Status:
Not open for further replies.

Share This Page