2018-01-25 17:34:45 +01:00
|
|
|
import javax.naming.ConfigurationException;
|
|
|
|
|
2018-01-25 10:53:51 +01:00
|
|
|
import net.knarcraft.serverlauncher.server.*;
|
2018-01-26 15:59:49 +01:00
|
|
|
|
|
|
|
import java.io.*;
|
2018-01-25 10:53:51 +01:00
|
|
|
|
2018-01-25 21:17:02 +01:00
|
|
|
/**
|
|
|
|
* A class for testing new and existing features.
|
|
|
|
*
|
|
|
|
* @author Kristian Knarvik <kristian.knarvik@knett.no>
|
|
|
|
* @version 0.0.0.1
|
|
|
|
* @since 0.0.0.1
|
|
|
|
*/
|
2018-01-26 20:34:15 +01:00
|
|
|
class ServerTest {
|
2018-01-26 15:59:49 +01:00
|
|
|
public static void main(String[] args) throws IOException {
|
2018-01-25 19:55:28 +01:00
|
|
|
try {
|
2018-01-25 21:17:02 +01:00
|
|
|
ServerType.loadServerTypes();
|
2018-01-25 17:34:45 +01:00
|
|
|
} catch (ConfigurationException e) {
|
|
|
|
e.printStackTrace();
|
2018-01-25 19:55:28 +01:00
|
|
|
System.exit(1);
|
2018-01-25 17:34:45 +01:00
|
|
|
}
|
2018-01-25 21:17:02 +01:00
|
|
|
new Server("Server1");
|
|
|
|
Server server1 = Server.getServers().get(0);
|
2018-01-25 10:53:51 +01:00
|
|
|
server1.toggle();
|
|
|
|
server1.setPath("C:\\Users\\Kristian\\Desktop\\Test");
|
2018-01-26 15:59:49 +01:00
|
|
|
server1.setType(ServerType.getServerTypes().get(4));
|
|
|
|
server1.setServerVersion("1.12.2");
|
2018-01-25 10:53:51 +01:00
|
|
|
server1.setMaxRam("1G");
|
2018-01-25 21:17:02 +01:00
|
|
|
Server.startServers();
|
2018-01-26 15:59:49 +01:00
|
|
|
|
|
|
|
OutputStream stdin = server1.getProcess().getOutputStream ();
|
|
|
|
InputStream stdout = server1.getProcess().getInputStream ();
|
|
|
|
|
|
|
|
BufferedReader reader = new BufferedReader (new InputStreamReader(stdout));
|
|
|
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin));
|
|
|
|
|
|
|
|
String line;
|
|
|
|
while ((line = reader.readLine ()) != null) {
|
|
|
|
System.out.println ("Stdout: " + line);
|
|
|
|
writer.write("stop\n");
|
|
|
|
writer.flush();
|
|
|
|
}
|
|
|
|
//writer.close();
|
2018-01-25 10:53:51 +01:00
|
|
|
}
|
|
|
|
}
|