Skip to content

Instantly share code, notes, and snippets.

@WoutDev
Last active November 4, 2015 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WoutDev/3f0bcf919691254807d9 to your computer and use it in GitHub Desktop.
Save WoutDev/3f0bcf919691254807d9 to your computer and use it in GitHub Desktop.
public void onEnable()
{
loadConfig();
}
private void loadConfig()
{
Path configDir = getDataFolder().toPath();
if (!Files.exists(configDir))
{
try
{
Files.createDirectory(configDir);
}
catch (IOException e)
{
e.printStackTrace();
}
}
Path configFile = Paths.get(getDataFolder().toPath().toString(), "config.yml");
if (!Files.exists(configFile))
{
try
{
Files.copy(getResource("config.yml"), configFile);
}
catch (IOException e)
{
e.printStackTrace();
}
}
configuration = YamlConfiguration.loadConfiguration(configFile.toFile()); // FileConfiguration object
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment