MCMarter

StatsConfig

Aug 16th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. package plugin.clickly.kitpvp.configs;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.logging.Logger;
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.Server;
  8. import org.bukkit.configuration.file.FileConfiguration;
  9. import org.bukkit.configuration.file.YamlConfiguration;
  10. import org.bukkit.plugin.Plugin;
  11. import org.bukkit.plugin.PluginDescriptionFile;
  12.  
  13. public class StatsConfig
  14. {
  15. static StatsConfig instance = new StatsConfig();
  16. Plugin plugin;
  17. FileConfiguration stats;
  18. File sfile;
  19.  
  20. public static StatsConfig getInstance()
  21. {
  22. return instance;
  23. }
  24.  
  25. public void setup(Plugin p)
  26. {
  27. this.sfile = new File(p.getDataFolder(), "Stats.yml");
  28. if (!this.sfile.exists()) {
  29. try
  30. {
  31. this.sfile.createNewFile();
  32. }
  33. catch (IOException e)
  34. {
  35. Bukkit.getServer().getLogger().severe("[KitPvP] Could not create Stats.yml!");
  36. }
  37. }
  38. this.stats = YamlConfiguration.loadConfiguration(this.sfile);
  39. }
  40.  
  41. public FileConfiguration getStats()
  42. {
  43. return this.stats;
  44. }
  45.  
  46. public void saveStats()
  47. {
  48. try
  49. {
  50. this.stats.save(this.sfile);
  51. }
  52. catch (IOException e)
  53. {
  54. Bukkit.getServer().getLogger().severe("[KitPvP] Could not save Stats.yml!");
  55. }
  56. }
  57.  
  58. public void reloadLocation()
  59. {
  60. this.stats = YamlConfiguration.loadConfiguration(this.sfile);
  61. }
  62.  
  63. public PluginDescriptionFile getDesc()
  64. {
  65. return this.plugin.getDescription();
  66. }
  67. }
Add Comment
Please, Sign In to add comment