Minecraft-Server-Launcher/test/ServerTest.java

46 lines
1.4 KiB
Java

import javax.naming.ConfigurationException;
import net.knarcraft.serverlauncher.server.*;
import java.io.*;
/**
* 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
*/
class ServerTest {
public static void main(String[] args) throws IOException {
try {
ServerType.loadServerTypes();
} catch (ConfigurationException e) {
e.printStackTrace();
System.exit(1);
}
new Server("Server1");
Server server1 = Server.getServers().get(0);
server1.toggle();
server1.setPath("C:\\Users\\Kristian\\Desktop\\Test");
server1.setType(ServerType.getServerTypes().get(4));
server1.setServerVersion("1.12.2");
server1.setMaxRam("1G");
Server.startServers();
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();
}
}