Fixed input and starting to firgure out how to do this
This commit is contained in:
parent
28eccfc954
commit
495e5b17d8
1 changed files with 10 additions and 9 deletions
|
@ -16,7 +16,7 @@ public class ServerRunner {
|
||||||
System.out.println("Starting server...");
|
System.out.println("Starting server...");
|
||||||
Process p = Runtime.getRuntime().exec(new String[] { "java", "-Xms512M", "-Xmx1024M", "-XX:MaxPermSize=128M",
|
Process p = Runtime.getRuntime().exec(new String[] { "java", "-Xms512M", "-Xmx1024M", "-XX:MaxPermSize=128M",
|
||||||
"-jar", "spigot-" + SERVER_VERSION + ".jar" });
|
"-jar", "spigot-" + SERVER_VERSION + ".jar" });
|
||||||
Thread t = new Thread() {
|
final Thread it = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PrintWriter output = new PrintWriter(p.getOutputStream());
|
PrintWriter output = new PrintWriter(p.getOutputStream());
|
||||||
|
@ -25,18 +25,20 @@ public class ServerRunner {
|
||||||
while (!stop) {
|
while (!stop) {
|
||||||
String readLine = br.readLine();
|
String readLine = br.readLine();
|
||||||
output.println(readLine);
|
output.println(readLine);
|
||||||
System.out.println("Read: " + readLine);
|
output.flush();
|
||||||
|
if (readLine.contains("stop"))
|
||||||
|
stop = true;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
stop = true; //TODO: Communicate with a plugin with console input
|
stop = true;
|
||||||
System.out.println("Stopped " + Thread.currentThread().getName());
|
System.out.println("Stopped " + Thread.currentThread().getName());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
t.setName("InputThread");
|
it.setName("InputThread");
|
||||||
t.start();
|
it.start();
|
||||||
t = new Thread() {
|
final Thread ot = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
@ -53,14 +55,13 @@ public class ServerRunner {
|
||||||
System.out.println("Stopped " + Thread.currentThread().getName());
|
System.out.println("Stopped " + Thread.currentThread().getName());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
t.setName("OutputThread");
|
ot.setName("OutputThread");
|
||||||
t.start();
|
ot.start();
|
||||||
Thread.currentThread().setName("RestarterThread");
|
Thread.currentThread().setName("RestarterThread");
|
||||||
while (!stop) {
|
while (!stop) {
|
||||||
Thread.sleep(10000);
|
Thread.sleep(10000);
|
||||||
System.out.println("RESTART");
|
System.out.println("RESTART");
|
||||||
}
|
}
|
||||||
System.out.println("Stopped " + Thread.currentThread().getName());
|
System.out.println("Stopped " + Thread.currentThread().getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue