Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Michielo.UltimateStats;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.nio.file.Files;
- import net.md_5.bungee.api.plugin.Plugin;
- import net.md_5.bungee.config.Configuration;
- import net.md_5.bungee.config.ConfigurationProvider;
- import net.md_5.bungee.config.YamlConfiguration;
- public class BungeeMain extends Plugin {
- @Override
- public void onEnable() {
- getLogger().info("\n \n---=== UltimateStats ===--- \n - Started \n---=== UltimateStats ===--- \n \n");
- // config
- saveDefaultConfig();
- }
- @Override
- public void onDisable() {
- getLogger().info("\n \n---=== UltimateStats ===--- \n - Closed \n---=== UltimateStats ===--- \n \n");
- }
- public Configuration getConfig() {
- try {
- Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
- return configuration;
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
- public void saveConfig() {
- try {
- ConfigurationProvider.getProvider(YamlConfiguration.class).save(getConfig(), new File(getDataFolder(), "config.yml"));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- private void saveDefaultConfig() {
- if (!getDataFolder().exists())
- getDataFolder().mkdir();
- File file = new File(getDataFolder(), "config.yml");
- if (!file.exists()) {
- try (InputStream in = getResourceAsStream("config.yml")) {
- Files.copy(in, file.toPath());
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment