Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. package me.MrAxe.BeastSpawners;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import org.bukkit.configuration.file.FileConfiguration;
  7. import org.bukkit.configuration.file.YamlConfiguration;
  8.  
  9.  
  10.  
  11. public class YmlCreator{
  12.  
  13. private BeastSpawners pl;
  14. private String name;
  15.  
  16. public YmlCreator(BeastSpawners plugin,String n){
  17. pl = plugin;
  18. name = n;
  19. createFiles(name);
  20. }
  21.  
  22.  
  23.  
  24. public File configf;
  25. public FileConfiguration config;
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. public void reloadConfig(){
  33. createFiles(name);
  34.  
  35. }
  36. public FileConfiguration getConfig() {
  37. return config;
  38. }
  39. public void saveConfig(){
  40. try {
  41. config.save(configf);
  42. } catch (IOException e) {
  43. // TODO Auto-generated catch block
  44. e.printStackTrace();
  45. }
  46. }
  47.  
  48.  
  49.  
  50.  
  51. public void createFiles(String name) {
  52.  
  53.  
  54.  
  55. configf = new File(pl.getDataFolder(), name);
  56.  
  57. if (!configf.exists()) {
  58. configf.getParentFile().mkdirs();
  59. pl.saveResource(name, false);
  60. }
  61.  
  62.  
  63. config = new YamlConfiguration();
  64.  
  65. try {
  66. config.load(configf);
  67. } catch (Exception e) {
  68. e.printStackTrace();
  69. }
  70.  
  71.  
  72.  
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement