This is for people who do not know how to create configuration files . Code: Code: package com.officeremerald.configurationapi; import java.io.File; import java.io.IOException; import org.bukkit.configuration.file.FileConfiguration; public class ConfigAPI { private static FileConfiguration config; public static FileConfiguration getConfig() { return config; } public static void setupConfiguration(String dataFolder, String[] string, String[] string2) { File configFile = new File("plugins/" + dataFolder + "", "config.yml"); if (configFile.exists()) return; for (String s : string) { config.set(s, string2); } try { config.save(configFile); } catch (IOException e1) { e1.printStackTrace(); } try { configFile.createNewFile(); } catch (Exception e) { e.printStackTrace(); } } public static void saveConfig(File fileDir) { try { config.save(fileDir); } catch (IOException e) { e.printStackTrace(); } } public static void setConfig(FileConfiguration config1){ config = config1; } } Usage (In onenable): Code: package com.officeremerald.configurationapi; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin { FileConfiguration config; String[] s = {"Messages.joinMes", "Messages.leaveMes"}; String[] s1 = {"Welcome to UHC!", "GoodBye!"}; public void onEnable(){ config = getConfig(); ConfigAPI.setConfig(config); ConfigAPI.setupConfiguration("ConfigAPI", s , s1); } } Usage(In getting config): Code: ConfigAPI.getConfig().getString("Messages.lol"); Note: For the first String, use the name you put in your plugin.yml file.
@OfficerDeveloper What if I want multiple configurations? What do I do then? And have you tested your code? I see a NPE already.
If you want multiple configurations you dont use my util. No need for the sass. And let me fix the NPE error, didnt see it there. Fixed the NPE. <Edit by mrCookieSlime: Merged posts. Please don't double post. There is an Edit Button right next to the Date.>
Like I said, most people who use this will not know how to make configs. This is just a tool to help them, not make multiple configs.
@OfficerDeveloper Well just make a post telling people to use "saveDefaultConfig()" and "getConfig()"...