package tech.nevets.jaml; import org.simpleyaml.configuration.file.YamlFile; import java.io.IOException; public class Config { private static final YamlFile YML_FILE = new YamlFile(JAML.path + "/config.yml"); public static void loadConfig() { YML_FILE.setConfigurationFile(JAML.path + "/config.yml"); try { if (!YML_FILE.exists()) { System.out.println("Config file not found, creating new one..."); YML_FILE.createNewFile(true); System.out.println("Config file created!"); } else { System.out.println("Loading Config file..."); YML_FILE.loadWithComments(); System.out.println("Config file loaded!"); } } catch (final Exception e) { System.out.println("Error while loading config file!"); e.printStackTrace(); } YML_FILE.setComment("java", "\n" + " JJJJJJJJJJJ AAA MMMMMMMM MMMMMMMM LLLLLLLLLLL \n" + " J:::::::::J A:::A M:::::::M M:::::::M L:::::::::L \n" + " J:::::::::J A:::::A M::::::::M M::::::::M L:::::::::L \n" + " JJ:::::::JJ A:::::::A M:::::::::M M:::::::::M LL:::::::LL \n" + " J:::::J A:::::::::A M::::::::::M M::::::::::M L:::::L \n" + " J:::::J A:::::A:::::A M:::::::::::M M:::::::::::M L:::::L \n" + " J:::::J A:::::A A:::::A M:::::::M::::M M::::M:::::::M L:::::L \n" + " J:::::j A:::::A A:::::A M::::::M M::::M M::::M M::::::M L:::::L \n" + " J:::::J A:::::A A:::::A M::::::M M::::M::::M M::::::M L:::::L \n" + " JJJJJJJ J:::::J A:::::AAAAAAAAA:::::A M::::::M M:::::::M M::::::M L:::::L \n" + " J:::::J J:::::J A:::::::::::::::::::::A M::::::M M:::::M M::::::M L:::::L \n" + " J::::::J J::::::J A:::::AAAAAAAAAAAAA:::::A M::::::M MMMMM M::::::M L:::::L LLLLLL\n" + " J:::::::JJJ:::::::J A:::::A A:::::A M::::::M M::::::M LL:::::::LLLLLLLLL:::::L\n" + " JJ:::::::::::::JJ A:::::A A:::::A M::::::M M::::::M L::::::::::::::::::::::L\n" + " JJ:::::::::JJ A:::::A A:::::A M::::::M M::::::M L::::::::::::::::::::::L\n" + " JJJJJJJJJ AAAAAAA AAAAAAA MMMMMMMM MMMMMMMM LLLLLLLLLLLLLLLLLLLLLLLL\n" ); YML_FILE.addDefault("java.jdk8", ""); YML_FILE.setComment("java.jdk8", "Set these to the bin directory of each JDK version"); YML_FILE.addDefault("java.jdk16", ""); YML_FILE.addDefault("java.jdk17", ""); YML_FILE.addDefault("game.show-snapshots", false); YML_FILE.addDefault("launcher.default-profile", ""); YML_FILE.setComment("launcher.default-profile", "Set's the profile that will be loaded automatically"); YML_FILE.addDefault("launcher.path","default"); YML_FILE.setComment("launcher.path","Path to JAML files\n" + "default: " + JAML.path.toString()); YML_FILE.addDefault("launcher.keep-open", false); YML_FILE.setComment("launcher.keep-open", "Keeps the launcher open after launching the game"); YML_FILE.addDefault("launcher.first-launch", true); YML_FILE.setComment("launcher.first-launch", "Do Not Change, will regenerate files"); YML_FILE.addDefault("launcher.auto-update", true); YML_FILE.setComment("launcher.auto-update", "Enables a simple automatic updates system."); YML_FILE.addDefault("launcher.verbose", false); YML_FILE.setComment("launcher.verbose", "If true, will print out all the messages"); YML_FILE.addDefault("launcher.version", JAML.VERSION); YML_FILE.set("launcher.version", JAML.VERSION); YML_FILE.setComment("launcher.version", "JAML version, don't change it!"); try { YML_FILE.save(); } catch (IOException e) { e.printStackTrace(); } } public static YamlFile getConfig() { return YML_FILE; } public static void reloadConfig() { CONFIG = getConfig(); } public static YamlFile CONFIG = getConfig(); public static void saveConfig() { try { YML_FILE.save(); } catch (IOException e) { e.printStackTrace(); } } public static void setValue(String path, Object data) { YML_FILE.set(path, data); saveConfig(); } }