Fixes casting problems
This commit is contained in:
@ -1,6 +1,3 @@
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import net.knarcraft.serverlauncher.server.*;
|
||||
@ -11,25 +8,36 @@ import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class ServerTest {
|
||||
private static ArrayList<ServerType> serverTypes = new ArrayList<>();
|
||||
private static ArrayList<Server> servers = new ArrayList<>();
|
||||
private static ArrayList<ServerType> serverTypes = new ArrayList<>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
/*try {
|
||||
try {
|
||||
loadServerTypes();
|
||||
} catch (ConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
System.exit(1);
|
||||
}
|
||||
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.setType(serverTypes.get(4));
|
||||
//TODO: All types are inside serverTypes, but the ones of ServerType get a casting error.
|
||||
server1.setServerVersion("1.12.2");
|
||||
server1.setMaxRam("1G");
|
||||
servers.add(server1);
|
||||
startServers(servers);*/
|
||||
startServers(servers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs all enabled servers with their settings.
|
||||
*/
|
||||
private static void startServers(ArrayList<Server> servers) {
|
||||
System.out.println("Starting servers.");
|
||||
for (Server server : servers) {
|
||||
server.run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all the valid server types and versions.
|
||||
@ -50,23 +58,13 @@ public class ServerTest {
|
||||
} else if (len == 3) {
|
||||
serverTypes.add(new ServerType(str[0], ver, str[2]));
|
||||
} else {
|
||||
throw new ConfigurationException("Error: Config file invalid.");
|
||||
throw new ConfigurationException("Error: Configuration file invalid.");
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new ConfigurationException("Error: Config file not found.");
|
||||
throw new ConfigurationException("Error: Configuration 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<Server> servers) {
|
||||
System.out.println("Starting servers.");
|
||||
for (Server server : servers) {
|
||||
server.run();
|
||||
throw new ConfigurationException("Error: Configuration file invalid.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user