Okay, so I am trying to copy a config.yml file from inside of mine jar out to my plugins folder I have done it before, but I don't remember how, now I think I have tried 7 different ways to do it, every time nothing happens. I have tested that the InputStream is correct, and I can get the data from the config.yml inside of my jar, but I can't copy it out to my plugin folders config.yml my code at the moment: Code (Java): config = new File(main.getDataFolder(), "config.yml"); configC = YamlConfiguration.loadConfiguration(config); InputStream input = this.getClass().getResourceAsStream("config.yml"); File in = new File(input.toString()); YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(in); configC.setDefaults(defConfig); configC.options().copyDefaults(true);
You can save any resource with your JavaPlugin instance plugin.saveResource("config.yml", false) for example. The boolean is for replacement
hmm it doesn't work :/ I've tried: Code (Text): main.saveResource(main.getClass().getResource("config.yml").getPath(), true); and main.saveResource(config.getPath(), true);
I'm on mobile, so I can't explain it, but read the wiki it will help you(hopefully) Your .yml file must be under src folder(if you are using maven under resource instead of src). By the way if you are using maven depending on your setting you must use the include tag. Edit: wording Editn 2: config.yml comes with bukkit you just need to run saveDefaults or something similar on #onEnable()
I don't use maven, and it is in my src I have no idea why it won't work And I already tried the saveDeafult...
Drag your config.yml directly onto your src folder. Then you just need to call saveResource("config.yml", false) no path, file or anything else. Just the name and the classloader will find it