Advertisement
Guest User

Settings

a guest
Sep 3rd, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. private Settings() {}
  2. private static Settings instance = new Settings();
  3. public static Settings getInstance() {
  4. return instance;
  5. }
  6.  
  7. private FileConfiguration data;
  8. private File dfile;
  9.  
  10. public void setup(Plugin p) {
  11. if (!p.getDataFolder().exists()) {
  12. p.getDataFolder().mkdir();
  13. }
  14.  
  15. dfile = new File(p.getDataFolder(), "data.yml");
  16.  
  17. if (!dfile.exists()) {
  18. try {
  19. dfile.createNewFile();
  20. } catch (IOException ex) {
  21. Bukkit.getServer().getLogger().severe(ChatColor.RED + "Could not create data.yml!");
  22. }
  23. }
  24.  
  25. data = YamlConfiguration.loadConfiguration(dfile);
  26. }
  27.  
  28. public FileConfiguration getData() {
  29. return data;
  30. }
  31. public void saveData() {
  32. try {
  33. data.save(dfile);
  34. } catch (IOException ex) {
  35. Bukkit.getServer().getLogger().severe(ChatColor.RED + "Could not save data.yml!");
  36. }
  37. }
  38. public void reloadData() {
  39. data = YamlConfiguration.loadConfiguration(dfile);
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement