Noob question regarding custom configs.

Discussion in 'Plugin Development' started by Superior_Slime, Jul 13, 2014.

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

    Superior_Slime

    Hey, I have a plugin (BedHome), and I'm currently making an update for it. I want to be able to save bed spawn locations to a seperate file named beds.yml rather than the config, but I have no idea how. Help would be appreciated, thanks.
     
  2. Offline

    EnderTroll68

    I will be assuming you are working with the file in your main class so just do the following:
    Code:java
    1. File file = new File(this.getDataFolder(), "beds.yml");
    2.  
    3. if(!file.exists()) {
    4. file.createNewFile();
    5. }
    6.  
    7. YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
     
    Superior_Slime and Europia79 like this.
  3. Offline

    Superior_Slime

    Thanks. Then to actually save to the file, what would I do? I'm sorry, I'm still working through the tutorials. I'm an idiot. yes I have googled it
     
  4. Offline

    EnderTroll68

    Superior_Slime likes this.
  5. Offline

    Superior_Slime

    Thanks, but I mean as in writing data to it, i.e. when someone right clicks a bed, it adds/changes the value of (their username) and inside that has their x, y and z
     
  6. Offline

    EnderTroll68

    yml.set("EnderTroll68.x", 0);
    yml.set("EnderTroll68.y", 75);
    yml.set("EnderTroll68.z", 0);
     
    Superior_Slime likes this.
  7. Offline

    ITaco

    Or to get the player same as EnderTroll do
    Code:java
    1. final Player p = org.bukkit.entity.Player;

    Then after that do:
    Code:
    yml.set("p.x", 0);
    yml.set("p.y", 75);
    yml.set("p.z", 0);
     
    Superior_Slime likes this.
  8. Offline

    Superior_Slime

  9. Offline

    ITaco

Thread Status:
Not open for further replies.

Share This Page