Jar compiling is now possible

This commit is contained in:
2018-01-26 23:15:19 +01:00
parent 1fafab78b6
commit 55c7c8defd
6 changed files with 43 additions and 33 deletions

View File

@ -49,32 +49,33 @@ public class ServerType {
*/
public static void loadServerTypes() throws ConfigurationException {
if (serverTypes.isEmpty()) {
try (Scanner in = new Scanner(new File("config/servertypes.csv"))) {
while (in.hasNextLine()) {
String[] str = in.nextLine().split(";", -1);
int len = str.length;
String[] ver;
if (str[1].contains(",")) {
ver = str[1].split(",", -1);
} else {
ver = new String[]{str[1]};
}
switch (len) {
case 7:
new AdvancedServerType(str[0], ver, str[2], str[3], str[4], str[5], str[6]);
break;
case 3:
new ServerType(str[0], ver, str[2]);
break;
default:
throw new ConfigurationException("Error: Configuration file invalid.");
}
}
Scanner file;
try {
file = new Scanner(new File("config/servertypes.csv"));
} catch (FileNotFoundException e) {
throw new ConfigurationException("Error: Configuration file not found.");
} catch (ArrayIndexOutOfBoundsException e) {
throw new ConfigurationException("Error: Configuration file invalid.");
file = new Scanner(ServerType.class.getResourceAsStream("/config/servertypes.csv"));
}
while (file.hasNextLine()) {
String[] str = file.nextLine().split(";", -1);
int len = str.length;
String[] ver;
if (str[1].contains(",")) {
ver = str[1].split(",", -1);
} else {
ver = new String[]{str[1]};
}
switch (len) {
case 7:
new AdvancedServerType(str[0], ver, str[2], str[3], str[4], str[5], str[6]);
break;
case 3:
new ServerType(str[0], ver, str[2]);
break;
default:
throw new ConfigurationException("Error: Configuration file invalid.");
}
}
} else {
throw new ConfigurationException("Error: Configuration already loaded.");
}