Guest User

mcasettings class

a guest
May 28th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. package me.uba;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6.  
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.ChatColor;
  9. import org.bukkit.configuration.file.FileConfiguration;
  10. import org.bukkit.configuration.file.YamlConfiguration;
  11. import org.bukkit.plugin.Plugin;
  12. import org.bukkit.plugin.PluginDescriptionFile;
  13.  
  14. public class mcasettings {
  15.  
  16. private mcasettings() { }
  17.  
  18. static mcasettings instance = new mcasettings();
  19.  
  20. public static mcasettings getInstance() {
  21. return instance;
  22. }
  23.  
  24. Plugin p;
  25.  
  26. FileConfiguration profile;
  27. File dfile;
  28.  
  29. public void setup(Plugin p) {
  30. dfile = new File(p.getDataFolder(), "playerinfo.yml");
  31.  
  32. if (!dfile.exists()) {
  33. try {
  34. dfile.createNewFile();
  35. }
  36. catch (IOException e) {
  37. Bukkit.getServer().getLogger().severe(ChatColor.RED + "Could not create playerinfo.yml!");
  38. }
  39. }
  40.  
  41. profile = YamlConfiguration.loadConfiguration(dfile);
  42. }
  43.  
  44. public FileConfiguration getData() {
  45. return profile;
  46. }
  47.  
  48. public void saveData() {
  49. try {
  50. profile.save(dfile);
  51. }
  52. catch (IOException e) {
  53. Bukkit.getServer().getLogger().severe(ChatColor.RED + "Could not save playerinfo.yml!");
  54. }
  55. }
  56.  
  57. public void reloadData() {
  58. profile = YamlConfiguration.loadConfiguration(dfile);
  59. }
  60.  
  61. public PluginDescriptionFile getDesc() {
  62. return p.getDescription();
  63. }
  64. }
Add Comment
Please, Sign In to add comment