Advertisement
jcgru

ConfigManager

Aug 10th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. public void Setup() throws IOException {
  2.         /*
  3.          YAML initialize
  4.          */
  5.         mainDir = main.getDataFolder();
  6.         // load as file
  7.         configFile = new File(mainDir, "config.yml");
  8.         messagesFile = new File(mainDir, "messages.yml");
  9.  
  10.         // directories
  11.         if(!mainDir.exists()){
  12.             mainDir.mkdirs();
  13.         }
  14.         // files exist
  15.         if(!configFile.exists()){
  16.             configFile.createNewFile();
  17.             try{
  18.                 DefaultConfig();
  19.             }catch (Exception e){
  20.                 e.printStackTrace();
  21.             }
  22.         }
  23.         if(!messagesFile.exists()){
  24.             configFile.createNewFile();
  25.             try {
  26.                 DefaultMessages();
  27.             }catch (Exception e){
  28.                 e.printStackTrace();
  29.             }
  30.         }
  31.         // load configs
  32.         YAMLParse yamlParse = new YAMLParse(main);
  33.         // INIT settings
  34.         settings.SetMap(yamlParse.ParseConfig(configFile.getName().replace(".yml", "") + ".yml"));
  35.         // INIT lang
  36.         //-------
  37.         lang.SetMap(yamlParse.ParseConfig(messagesFile.getName().replace(".yml", "") + ".yml"));
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement