Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. package eu.tryb4.W.map;
  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. import org.bukkit.plugin.Plugin;
  11.  
  12. public class storage {
  13. public storage() {}
  14. Plugin p;
  15. FileConfiguration data;
  16. File dfile;
  17. public void setup(Plugin p) {
  18. if (!p.getDataFolder().exists()) {
  19. p.getDataFolder().mkdir();
  20. }
  21.  
  22. dfile = new File(p.getDataFolder(), "storage.yml");
  23. if (!dfile.exists()) {
  24. try {
  25. dfile.createNewFile();
  26. System.out.println("Config> Generating storage.yml");
  27. }
  28. catch (IOException e) {
  29. Bukkit.getServer().getLogger().severe(ChatColor.RED + "Could not create storage.yml!");
  30. }
  31. }
  32.  
  33. data = YamlConfiguration.loadConfiguration(dfile);
  34. }
  35.  
  36. public FileConfiguration get() {
  37. return data;
  38. }
  39. public void delete() {
  40. if(dfile.exists()){
  41. dfile.delete();
  42. }
  43. }
  44.  
  45. public File file() {
  46. return dfile;
  47. }
  48.  
  49. public void save() {
  50. try {
  51. data.save(dfile);
  52. }
  53. catch (IOException e) {
  54. Bukkit.getServer().getLogger().severe(ChatColor.RED + "Could not save storage.yml!");
  55. }
  56. }
  57. public void reload() {
  58. data = YamlConfiguration.loadConfiguration(dfile);
  59. }
  60.  
  61.  
  62.  
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement