Comment and code additions
More comments are added. More work on downloading server jars is done. Server test added.
This commit is contained in:
parent
b6685edc6f
commit
0c2c26e153
@ -127,6 +127,7 @@ public class Server {
|
||||
throw new FileNotFoundException("Version file could not be downloaded.");
|
||||
}
|
||||
newestVersion = stringBetween(versionText, type.getSrcStart(), type.getSrcEnd());
|
||||
System.out.println(newestVersion);
|
||||
success = downloadFile(type.getDownloadURL() + newestVersion + type.getDownloadURLPart() + newestVersion + ".jar", filePath);
|
||||
//TODO: Register the new version number, and only download if version mismatch or missing file.
|
||||
if (!success) {
|
||||
@ -208,6 +209,7 @@ public class Server {
|
||||
* @return The wanted substring.
|
||||
*/
|
||||
private String stringBetween(String string, String start, String end) {
|
||||
return string.substring(string.indexOf(start) + 1 + start.length(), string.indexOf(end));
|
||||
int startPos = string.indexOf(start) + start.length();
|
||||
return string.substring(startPos, string.indexOf(end, startPos));
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
import net.knarcraft.serverlauncher.server.*;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ServerTest {
|
||||
@ -44,17 +43,24 @@ public class ServerTest {
|
||||
if (server.isEnabled()) {
|
||||
String path = server.getPath();
|
||||
String type = server.getType();
|
||||
try {
|
||||
/* try {
|
||||
server.downloadJar();
|
||||
System.out.println("File downloaded.");
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("File was not found.");
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
String ram = server.maxRam();
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
try {
|
||||
Process pr = rt.exec("java -Xmx" + ram + " -Xms512M -jar " + "\"" + path + "\\" + type + "\" nogui");
|
||||
Process pr = rt.exec("java -Xmx" + ram + " -Xms512M -jar " + "\"" + path + "\\" + type + "\"", null, new File(server.getPath()));
|
||||
String line;
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(pr.getInputStream()) );
|
||||
while ((line = in.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
in.close();
|
||||
long pid = pr.pid();
|
||||
server.updatePid(pid);
|
||||
System.out.println("Success");
|
||||
|
Loading…
Reference in New Issue
Block a user