Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. package me.Nighterance.main;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.configuration.file.FileConfiguration;
  9. import org.bukkit.configuration.file.YamlConfiguration;
  10.  
  11. public class ConfigManager {
  12.  
  13. private BottleBets plugin = BottleBets.getPlugin(BottleBets.class);
  14.  
  15. // Files & File Configs Here
  16. public FileConfiguration potionsconfig;
  17. public File potionsfile;
  18. // --------------------------
  19.  
  20. public void setup() {
  21. if (!plugin.getDataFolder().exists()) {
  22. plugin.getDataFolder().mkdir();
  23. }
  24.  
  25. potionsfile = new File(plugin.getDataFolder(), "potions.yml");
  26.  
  27. if (!potionsfile.exists()) {
  28. try {
  29. potionsfile.createNewFile();
  30. Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "We did it! potions.yml file was generated. Woohoo!");
  31. } catch (IOException e) {
  32. Bukkit.getServer().getConsoleSender()
  33. .sendMessage(ChatColor.RED + "Whait, what? We could not generate potions.yml. Why?");
  34. }
  35. }
  36.  
  37. potionsconfig = YamlConfiguration.loadConfiguration(potionsfile);
  38. }
  39.  
  40. public FileConfiguration getPlayers() {
  41. return potionsconfig;
  42. }
  43.  
  44. public void savePlayers() {
  45. try {
  46. potionsconfig.save(potionsfile);
  47. Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "We just saved potions.yml");
  48.  
  49. } catch (IOException e) {
  50. Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "We could not save potions.yml");
  51. }
  52. }
  53.  
  54. public void reloadPlayers() {
  55. potionsconfig = YamlConfiguration.loadConfiguration(potionsfile);
  56. Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.BLUE + "We reloaded potions.yml file");
  57.  
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement