-
-
Save WoutDev/3f0bcf919691254807d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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