Advertisement
Guest User

Untitled

a guest
Dec 31st, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. package me.mrson.McEconPlus.Utils;
  2.  
  3. import com.sun.glass.ui.Window;
  4. import me.mrson.McEconPlus.MCEP_Base;
  5. import org.bukkit.configuration.file.FileConfiguration;
  6. import org.bukkit.configuration.file.YamlConfiguration;
  7. import org.bukkit.plugin.Plugin;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9.  
  10. import java.io.File;
  11. import java.io.IOException;
  12. import java.io.InputStreamReader;
  13. import java.io.Reader;
  14. import java.util.logging.Level;
  15.  
  16.  
  17. /**
  18. * Created by Dominic on 10/6/2014.
  19. */
  20. public class MCEP_Config extends JavaPlugin {
  21. private static MCEP_Base plugin;
  22.  
  23. private static File dataFolder;
  24.  
  25. private static File configFile;
  26.  
  27. private static FileConfiguration config;
  28.  
  29. @SuppressWarnings("static-access")
  30. public MCEP_Config(MCEP_Base plugin){
  31. this.plugin = plugin;
  32.  
  33. this.dataFolder = plugin.getDataFolder();
  34.  
  35. this.configFile = new File(plugin.getDataFolder(), "config.yml");
  36.  
  37. this.config = YamlConfiguration.loadConfiguration(configFile);
  38. }
  39.  
  40.  
  41.  
  42. public static void createConfigs(){
  43. if(!configFile.exists()){
  44. plugin.getLogger().log(Level.ALL, "Creating config...");
  45. plugin.saveResource("config.yml", true);
  46. plugin.getLogger().log(Level.ALL, "Config created.");
  47. }
  48. }
  49.  
  50. public static File getConfigFile(){
  51. return configFile;
  52. }
  53.  
  54. public static FileConfiguration getConfigs(){
  55. return config;
  56. }
  57.  
  58. public static void saveConfigFile(){
  59. saveFile(configFile, config);
  60. }
  61.  
  62. public static void saveFile(File file, FileConfiguration config){
  63. try{
  64. config.save(file);
  65. }catch(IOException e){
  66. e.printStackTrace();
  67. }
  68. }
  69.  
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement