import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.naming.ConfigurationException; import net.knarcraft.serverlauncher.server.*; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class ServerTest { private static ArrayList serverTypes = new ArrayList<>(); private static ArrayList servers = new ArrayList<>(); public static void main(String[] args) { /*try { loadServerTypes(); } catch (ConfigurationException e) { e.printStackTrace(); return; } Server server1 = new Server("Server1"); server1.toggle(); server1.setPath("C:\\Users\\Kristian\\Desktop\\Test"); server1.setType((AdvancedServerType) serverTypes.get(2)); server1.setServerVersion("1.10.2"); server1.setMaxRam("1G"); servers.add(server1); startServers(servers);*/ } /** * Adds all the valid server types and versions. */ private static void loadServerTypes() throws ConfigurationException { 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]}; } if (len == 7) { serverTypes.add(new AdvancedServerType(str[0], ver, str[2], str[3], str[4], str[5], str[6])); } else if (len == 3) { serverTypes.add(new ServerType(str[0], ver, str[2])); } else { throw new ConfigurationException("Error: Config file invalid."); } } } catch (FileNotFoundException e) { throw new ConfigurationException("Error: Config file not found."); } catch (ArrayIndexOutOfBoundsException e) { throw new ConfigurationException("Error: Config file invalid."); } } /** * Runs all enabled servers with their settings. */ public static void startServers(ArrayList servers) { System.out.println("Starting servers."); for (Server server : servers) { server.run(); } } }