JAML/src/main/java/tech/nevets/jaml/Config.java
2022-03-23 20:38:30 -04:00

179 lines
9.5 KiB
Java

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("launcher.default-profile", "default");
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.first-launch", true);
YML_FILE.setComment("launcher.first-launch", "Do Not Change, will regenerate files");
YML_FILE.addDefault("launcher.verbose", false);
YML_FILE.setComment("launcher.verbose", "If true, will print out all the messages");
YML_FILE.addDefault("launcher.version", "0.1.0");
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);
}
}
//package tech.nevets.jaml.util;
//
//import org.simpleyaml.configuration.file.YamlFile;
//import tech.nevets.jaml.JAML;
//
//import java.io.IOException;
//
//public class Config {
// private static final YamlFile YML_FILE = new YamlFile(JAML.path + "\\config.yml");
//
// public static void loadConfig() {
// 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.skin", "");
// YML_FILE.setComment("game.skin", "Current skin being used, DO NOT change this");
// YML_FILE.addDefault("launcher.default-profile", "default");
// 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.first-launch", true);
// YML_FILE.setComment("launcher.first-launch", "Do Not Change, will regenerate files");
// YML_FILE.addDefault("launcher.verbose", false);
// YML_FILE.setComment("launcher.verbose", "If true, will print out all the messages");
// YML_FILE.addDefault("launcher.version", "0.1.0");
// 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 saveConfig() {
// try {
// YML_FILE.save();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public static void setValue(String path, Object data) {
// YML_FILE.set(path, data);
// }
//}