Search code examples
javabukkit

How do I create a custom configuration file in my Bukkit Plugin?


I've been trying for days to learn how to make my own custom Bukkit Plugin Config File, with it's own name. I have tried creating the file, doing this:

    public static File warps = new File("warps.yml");
    public static FileConfiguration config = YamlConfiguration.loadConfiguration(warps);

So, as you can see, I have correctly defined all the necessary variables, and have even created methods in the past to make this simpler, but I can never find out a way to path my "config" to edit my "warps".

EDIT: My question is how to PATH "config" to "warps", because I don't want it to edit the "config.yml", I want it to edit the "File warps = new File("warps.yml");


Solution

  • Hello I had the same problem. You need to give the path name for the config file. The code below works for me when creating custom configuration files for players in a different map.

            file = new File(plugin.getDataFolder()+"\\player_stats", "statistics_"+player.getName() + ".yml");
        FileConfiguration playerStatistics = YamlConfiguration.loadConfiguration(file);
    

    The only thing you need to do is to change your file destination probably in this.

    public static File warps = new File(plugin.getDataFolder(), "warps.yml");
    

    I think this will work :)