Config Problems

Discussion in 'Plugin Development' started by dart2112, Jan 22, 2015.

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

    dart2112

    This is my code, it doesn't throw any errors but it doesn't write to the file. the file is created but nothing is written to it. I assume its aether the way I'm setting the values or the way i setup the YAMLConfiguration because the path is right because the file is created with file.createnewfile but it doesn't have anything in it.
    Code (open)

    Code:
    File file = new File(plugin.getDataFolder().getAbsolutePath() + File.separator
                    + "PlayerData" + File.separator + player.getUniqueId() + ".yml");
            FileConfiguration getHomes = YamlConfiguration.loadConfiguration(file);
    
    if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                    plugin.console
                            .sendMessage("[HomeSpawn] Player Data File Creation Failed!");
                    return;
                }
                    getHomes.createSection("HasHome");
                    try {
                        getHomes.save(file);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    getHomes.set("HasHome", "No");
                    try {
                        getHomes.save(file);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                plugin.spawnnew(player);
                getHomes.createSection("name");
                getHomes.set("name", player.getName());
                plugin.console.sendMessage(ChatColor.GOLD
                        + "[HomeSpawn] Blank Config Has Been Created For "
                        + player.getName());
                try {
                    getHomes.save(file);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

    that's not all of my code but its all that is used for this file.
    hope someone can help, and thanks in advance.
     
  2. Instead of using "getHomes.createSection("HasHome");" just use "getHomes.set("HasHome", "No");"
     
  3. Offline

    dart2112

    thank you
     
Thread Status:
Not open for further replies.

Share This Page