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

View File

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

View File

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