Adding new serverstart option for startup change #3
@ -39,7 +39,7 @@ public class Subserver implements Runnable {
|
||||
|
||||
private final String serverName;
|
||||
private final Runnable shutdownCallback;
|
||||
private final Process p;
|
||||
private final Process process;
|
||||
private final PrintWriter writer;
|
||||
private final ServerInfo server;
|
||||
private final Servertype type;
|
||||
@ -62,7 +62,7 @@ public class Subserver implements Runnable {
|
||||
this.shutdownCallback = shutdownCallback;
|
||||
|
||||
try{
|
||||
this.p = processBuilder.start();
|
||||
this.process = processBuilder.start();
|
||||
|
||||
}catch(IOException e){
|
||||
throw new SecurityException("Server could not be started", e);
|
||||
}
|
||||
@ -70,7 +70,7 @@ public class Subserver implements Runnable {
|
||||
InetSocketAddress address = new InetSocketAddress("127.0.0.1", port);
|
||||
this.server = ProxyServer.getInstance().constructServerInfo(
|
||||
serverName, address, "SteamWar.de - Subserver", false);
|
||||
this.writer = new PrintWriter(p.getOutputStream(), true);
|
||||
this.writer = new PrintWriter(process.getOutputStream(), true);
|
||||
|
||||
ProxyServer.getInstance().getScheduler().runAsync(Persistent.getInstance(), this);
|
||||
}
|
||||
@ -94,8 +94,8 @@ public class Subserver implements Runnable {
|
||||
public void stop(){
|
||||
writer.println("stop");
|
||||
try {
|
||||
if(!p.waitFor(1, TimeUnit.MINUTES))
|
||||
p.destroy();
|
||||
if(!process.waitFor(1, TimeUnit.MINUTES))
|
||||
process.destroy();
|
||||
}catch(InterruptedException e){
|
||||
logger.log(Level.SEVERE, "Subserver stop interrupted!", e);
|
||||
Thread.currentThread().interrupt();
|
||||
@ -124,7 +124,7 @@ public class Subserver implements Runnable {
|
||||
ProxyServer.getInstance().getServers().put(serverName, server);
|
||||
serverList.add(this);
|
||||
|
||||
try(BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()))){
|
||||
try(BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))){
|
||||
String line = "";
|
||||
while (!started && (line = reader.readLine()) != null) {
|
||||
started = line.contains("ViaVersion detected server version");
|
||||
@ -144,7 +144,7 @@ public class Subserver implements Runnable {
|
||||
}
|
||||
cachedPlayers.clear();
|
||||
|
||||
p.waitFor();
|
||||
process.waitFor();
|
||||
} catch(IOException e) {
|
||||
logger.log(Level.SEVERE, "Server " + serverName + " was interrupted!", e);
|
||||
fatalError();
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
"p" als Name für eine Variable ist nicht gerade viel aussagend!