Custom Config always returns false.

Discussion in 'Plugin Development' started by BurnerDiamond, May 11, 2015.

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

    BurnerDiamond

    I have this custom config:

    Code:
     public void createPlayerConfig(Player p) throws IOException {
    
            FileConfiguration fileConfiguration;
            File file = new File(Core.getInstance().getDataFolder() + File.separator + p.getUniqueId() + ".yml");
    
            if (!file.exists()) {
                file.createNewFile();
                fileConfiguration = YamlConfiguration.loadConfiguration(file);
                fileConfiguration.set("name", p.getName());
                fileConfiguration.set("mounts.chicken", true);
                fileConfiguration.set("mounts.cow", true);
                fileConfiguration.set("mounts.pig", true);
                fileConfiguration.set("mounts.sheep", true);
                fileConfiguration.set("mounts.zombie", true);
                fileConfiguration.set("mounts.creeper", true);
                fileConfiguration.set("mounts.skeleton", true);
                fileConfiguration.set("mounts.spider", true);
                fileConfiguration.set("mounts.enderman", true);
                fileConfiguration.save(file);
    
            }
        }
    And I use this to get it:

    Code:
        public static FileConfiguration getPlayerConfig(Player p) {
    
            File plugins = Core.getInstance().getDataFolder().getParentFile();
            File folder = new File(plugins.getPath() + File.separator + p.getUniqueId() + ".yml");
            FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(folder);
    
            return fileConfiguration;
        }
    
    It always returns false, and I'm not sure why. Any help?
     
  2. Online

    timtower Administrator Administrator Moderator

    @BurnerDiamond What returns false? There is nothing that can return false.
     
  3. Offline

    nbrandwine

    @timtower I think his method on getting the fileconfig is returning false, like it's not getting the config successfully.
     
  4. Offline

    BurnerDiamond

    Sorry meant to say when I try to retrieve mounts.chicken it returns the Boolean false rather than true.
     
  5. Online

    timtower Administrator Administrator Moderator

    @BurnerDiamond Saving and loading would be easier if the files would be in the same place, check where the folders are pointing.
     
    nbrandwine likes this.
  6. Offline

    BurnerDiamond

    Okay, will double check.
     
Thread Status:
Not open for further replies.

Share This Page