Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. public class FileManager {
  2. private File config;
  3. private YamlConfiguration yml;
  4. private String name;
  5.  
  6.  
  7. public FileManager(String path, String name) {
  8. File file = new File(path);
  9. if(!file.exists()) {
  10. file.mkdir();
  11. }
  12. this.config= new File(path + "/" + name + ".yml");
  13. this.name=name;
  14. }
  15.  
  16. public void create() {
  17. if(!this.config.exists()) {
  18. try {
  19. this.config.createNewFile();
  20. }
  21. catch (IOException e) {}
  22.  
  23. }
  24. }
  25.  
  26. public void save() {
  27. try {
  28. yml.save(config);
  29. }
  30. catch (IOException ioe) {}
  31. }
  32.  
  33. public File getFile() {
  34. return config;
  35. }
  36.  
  37. public void set(String path, Object obj) {
  38. yml.set(path, obj);
  39. save();
  40. }
  41.  
  42.  
  43. public void load() {
  44. this.yml=YamlConfiguration.loadConfiguration(this.config);
  45. }
  46.  
  47. public void delete(){
  48. this.config.delete();
  49. }
  50.  
  51. public YamlConfiguration getYml() {
  52. return this.yml;
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement