Escad

Untitled

Feb 1st, 2019
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. public class Config extends YamlConfiguration {
  2.  
  3.     private MyPlugin plugin;
  4.     private File file;
  5.  
  6.     public Config(MyPlugin plugin, String name) {
  7.         this.plugin = plugin;
  8.         this.file = new File(plugin.getDataFolder(), name);
  9.         reloadFile();
  10.     }
  11.  
  12.     public void reloadFile() {
  13.         if (!file.exists()) {
  14.             file.getParentFile().mkdirs();
  15.             plugin.saveResource(name);
  16.         }
  17.  
  18.         try {
  19.             load(file);
  20.         } catch (IOException | InvalidConfigurationException err) {
  21.             err.printStackTrace();
  22.         }
  23.     }
  24.  
  25.     public void saveFile() {
  26.         try {
  27.             save(file);
  28.         } catch (IOException err) {
  29.             err.printStackTrace();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment