Fixes issue #1

This commit is contained in:
Kristian Knarvik 2018-02-20 13:39:21 +01:00
parent 0f01a64f07
commit 379d1ed051
3 changed files with 13 additions and 6 deletions

View File

@ -4,7 +4,6 @@ import net.knarcraft.serverlauncher.profile.Collection;
import net.knarcraft.serverlauncher.profile.Profile; import net.knarcraft.serverlauncher.profile.Profile;
import net.knarcraft.serverlauncher.server.Server; import net.knarcraft.serverlauncher.server.Server;
import net.knarcraft.serverlauncher.server.ServerType; import net.knarcraft.serverlauncher.server.ServerType;
import net.knarcraft.serverlauncher.userinterface.GUI;
import net.knarcraft.serverlauncher.userinterface.ServerConsoles; import net.knarcraft.serverlauncher.userinterface.ServerConsoles;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
@ -79,6 +78,9 @@ public class Main {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (!server.getProcess().isAlive()) {
server.stopped();
}
} }
} }
} }

View File

@ -131,6 +131,12 @@ public class Server {
return this.playerList; return this.playerList;
} }
public void stopped() {
process = null;
writer = null;
reader = null;
}
/** /**
* @return A representation of the name of a jarfile. * @return A representation of the name of a jarfile.
*/ */
@ -298,11 +304,11 @@ public class Server {
public String read() throws IOException { public String read() throws IOException {
String line; String line;
if ((line = reader.readLine()) != null) { StringBuilder text = new StringBuilder();
return line; while (reader.ready() && (line = reader.readLine()) != null) {
} else { text.append(line).append("\n");
return "";
} }
return text.toString().trim();
} }
/** /**

View File

@ -1,6 +1,5 @@
package net.knarcraft.serverlauncher.userinterface; package net.knarcraft.serverlauncher.userinterface;
import net.knarcraft.serverlauncher.Main;
import net.knarcraft.serverlauncher.profile.Profile; import net.knarcraft.serverlauncher.profile.Profile;
import net.knarcraft.serverlauncher.server.Server; import net.knarcraft.serverlauncher.server.Server;
import net.knarcraft.serverlauncher.server.ServerType; import net.knarcraft.serverlauncher.server.ServerType;