Merge 71ef49ed11e8b2d0a7b0ceb7fce56f46799dd60d into 5121ab6f0113905232601b8efbeb9d170d189251
This commit is contained in:
commit
f64ea444e3
@ -170,6 +170,8 @@ public class FileRead {
|
|||||||
} else {
|
} else {
|
||||||
var.waitSave = false;
|
var.waitSave = false;
|
||||||
}
|
}
|
||||||
|
} else if (property.equals("postShutdownDelay")) {
|
||||||
|
var.postShutdownDelay = value.toLowerCase().equals("true") ? true : false;
|
||||||
} else if (property.equals("weblaunch")) {
|
} else if (property.equals("weblaunch")) {
|
||||||
if (value.toLowerCase().equals("true")) {
|
if (value.toLowerCase().equals("true")) {
|
||||||
var.webLaunch = true;
|
var.webLaunch = true;
|
||||||
|
@ -102,6 +102,8 @@ public class FileWrite {
|
|||||||
+ var.newLine
|
+ var.newLine
|
||||||
+ "#Optional: Wait a few seconds after saving." + var.newLine
|
+ "#Optional: Wait a few seconds after saving." + var.newLine
|
||||||
+ "WaitSave=false" + var.newLine
|
+ "WaitSave=false" + var.newLine
|
||||||
|
+ "#Optional: Wait a few seconds after server shutdown for OS memory housekeeping."
|
||||||
|
+ "postShutdownDelay=false"
|
||||||
+ "webLaunch=true";
|
+ "webLaunch=true";
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
|
@ -32,13 +32,20 @@ public class Server {
|
|||||||
if (var.verbose) {
|
if (var.verbose) {
|
||||||
Out.out("Starting server.");
|
Out.out("Starting server.");
|
||||||
}
|
}
|
||||||
|
int startCount = 0;
|
||||||
|
|
||||||
boolean serverSuccess = true;
|
boolean serverSuccess = true;
|
||||||
boolean warning = false;
|
boolean warning = false;
|
||||||
boolean warningsWeCanIgnore = false;
|
boolean warningsWeCanIgnore = false;
|
||||||
|
boolean serverDoneReceived = false;
|
||||||
final boolean ignoreWarningsOriginal = var.ignoreWarnings;
|
final boolean ignoreWarningsOriginal = var.ignoreWarnings;
|
||||||
|
|
||||||
// monitor output and print to console where required.
|
// monitor output and print to console where required.
|
||||||
// STOP the server when it's done.
|
// STOP the server when it's done.
|
||||||
|
while (serverSuccess && !serverDoneReceived) {
|
||||||
|
if (++startCount > 1)
|
||||||
|
Out.outP("Restarting server, try #" + startCount
|
||||||
|
+ ": did not receive \"" + var.doneText + "\"\n");
|
||||||
|
|
||||||
if (var.alternate) { // Alternate - a replication (slightly stripped down) of MLG 1.3.0's code. simplest code possible.
|
if (var.alternate) { // Alternate - a replication (slightly stripped down) of MLG 1.3.0's code. simplest code possible.
|
||||||
Out.out("Alternate Launch");
|
Out.out("Alternate Launch");
|
||||||
@ -52,7 +59,8 @@ public class Server {
|
|||||||
final BufferedReader pOut =
|
final BufferedReader pOut =
|
||||||
new BufferedReader(new InputStreamReader(process.getInputStream()));
|
new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
String line;
|
String line;
|
||||||
while ((line = pOut.readLine()) != null) { // readLine() returns null when the process exits
|
while ((line = pOut.readLine())
|
||||||
|
!= null) { // readLine() returns null when the process exits
|
||||||
|
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
|
|
||||||
@ -60,6 +68,8 @@ public class Server {
|
|||||||
if (line.contains(var.doneText)) { // EDITED By Morlok8k for Minecraft 1.3+ Beta
|
if (line.contains(var.doneText)) { // EDITED By Morlok8k for Minecraft 1.3+ Beta
|
||||||
final OutputStream outputStream = process.getOutputStream();
|
final OutputStream outputStream = process.getOutputStream();
|
||||||
|
|
||||||
|
serverDoneReceived = true;
|
||||||
|
|
||||||
Out.out("Stopping server... (Please Wait...)");
|
Out.out("Stopping server... (Please Wait...)");
|
||||||
outputStream.write(saveAll);
|
outputStream.write(saveAll);
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
@ -86,22 +96,26 @@ public class Server {
|
|||||||
String outTmp = "";
|
String outTmp = "";
|
||||||
String outTmp2 = null;
|
String outTmp2 = null;
|
||||||
|
|
||||||
final byte[] stop = { 's', 't', 'o', 'p', '\r', '\n' }; // Moved here, so this code wont run every loop, thus Faster!
|
final byte[] stop = {'s', 't', 'o', 'p', '\r',
|
||||||
|
'\n'}; // Moved here, so this code wont run every loop, thus Faster!
|
||||||
// and no, i can't use a string here!
|
// and no, i can't use a string here!
|
||||||
|
|
||||||
final byte[] saveAll = {'s', 'a', 'v', 'e', '-', 'a', 'l', 'l', '\r', '\n'};
|
final byte[] saveAll = {'s', 'a', 'v', 'e', '-', 'a', 'l', 'l', '\r', '\n'};
|
||||||
|
|
||||||
boolean prepTextFirst = true;
|
boolean prepTextFirst = true;
|
||||||
|
|
||||||
final OutputStream outputStream = process.getOutputStream(); // moved here to remove some redundancy
|
final OutputStream outputStream = process
|
||||||
|
.getOutputStream(); // moved here to remove some redundancy
|
||||||
|
|
||||||
boolean convertedMapFormattingFlag = false; // This allows MLG to track if we converted a map to a new format (such as Chunk-file -> McRegion, or McRegion -> Anvil)
|
boolean convertedMapFormattingFlag = false; // This allows MLG to track if we converted a map to a new format (such as Chunk-file -> McRegion, or McRegion -> Anvil)
|
||||||
// just so it gets a line ending after the % output finishes
|
// just so it gets a line ending after the % output finishes
|
||||||
while ((line = pOut.readLine()) != null) { // readLine() returns null when the process exits
|
while ((line = pOut.readLine())
|
||||||
|
!= null) { // readLine() returns null when the process exits
|
||||||
|
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
|
|
||||||
final int posBracket = line.indexOf("]"); //changed from .lastIndexOf to .indexOf, in case we have a custom server that outputs something with an "]". we want the first one anyways.
|
final int posBracket = line.indexOf(
|
||||||
|
"]"); //changed from .lastIndexOf to .indexOf, in case we have a custom server that outputs something with an "]". we want the first one anyways.
|
||||||
if (posBracket != -1) {
|
if (posBracket != -1) {
|
||||||
if ((posBracket + 2) >= line.length()) {
|
if ((posBracket + 2) >= line.length()) {
|
||||||
shortLine = line; //On error messages with 1.7 based servers, there is a "]" at the end of the line. caused a crash here.
|
shortLine = line; //On error messages with 1.7 based servers, there is a "]" at the end of the line. caused a crash here.
|
||||||
@ -110,7 +124,8 @@ public class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shortLine != null) {
|
if (shortLine != null) {
|
||||||
shortLine = shortLine.trim(); // new version of Eclipse was giving a warning that it could be null here - it can't, since "shortLine" is based on "line" which is never null at this point.
|
shortLine = shortLine
|
||||||
|
.trim(); // new version of Eclipse was giving a warning that it could be null here - it can't, since "shortLine" is based on "line" which is never null at this point.
|
||||||
} // added this check to remove warning, as i didn't want to suppress all null warnings for runMinecraft
|
} // added this check to remove warning, as i didn't want to suppress all null warnings for runMinecraft
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -139,7 +154,8 @@ public class Server {
|
|||||||
prepTextFirst = false;
|
prepTextFirst = false;
|
||||||
} else {
|
} else {
|
||||||
//Main.outP(" " + outTmp + "...");
|
//Main.outP(" " + outTmp + "...");
|
||||||
Out.outP("\r" + var.MLG + outTmp + "..."); //here we use \r to go back to the previous line, and rewrite it
|
Out.outP("\r" + var.MLG + outTmp
|
||||||
|
+ "..."); //here we use \r to go back to the previous line, and rewrite it
|
||||||
}
|
}
|
||||||
|
|
||||||
//}
|
//}
|
||||||
@ -153,38 +169,58 @@ public class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (line.contains("level 0")) { // "Preparing start region for level 0"
|
if (line.contains("level 0")) { // "Preparing start region for level 0"
|
||||||
Out.outP(var.MLG + var.worldName + ": " + var.level_0 + ":" + var.newLine);
|
Out.outP(
|
||||||
} else if (line.contains("level 1")) { // "Preparing start region for level 1"
|
var.MLG + var.worldName + ": " + var.level_0 + ":" + var.newLine);
|
||||||
Out.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_1 + ":"
|
} else if (line
|
||||||
|
.contains("level 1")) { // "Preparing start region for level 1"
|
||||||
|
Out.outP(
|
||||||
|
var.newLine + var.MLG + var.worldName + ": " + var.level_1 + ":"
|
||||||
+ var.newLine);
|
+ var.newLine);
|
||||||
} else if (line.contains("level 2")) { // "Preparing start region for level 2"
|
} else if (line
|
||||||
Out.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_2 + ":"
|
.contains("level 2")) { // "Preparing start region for level 2"
|
||||||
|
Out.outP(
|
||||||
|
var.newLine + var.MLG + var.worldName + ": " + var.level_2 + ":"
|
||||||
+ var.newLine);
|
+ var.newLine);
|
||||||
} else if (line.contains("level 3")) { // "Preparing start region for level 3"
|
} else if (line
|
||||||
Out.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_3 + ":"
|
.contains("level 3")) { // "Preparing start region for level 3"
|
||||||
|
Out.outP(
|
||||||
|
var.newLine + var.MLG + var.worldName + ": " + var.level_3 + ":"
|
||||||
+ var.newLine);
|
+ var.newLine);
|
||||||
} else if (line.contains("level 4")) { // "Preparing start region for level 4"
|
} else if (line
|
||||||
Out.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_4 + ":"
|
.contains("level 4")) { // "Preparing start region for level 4"
|
||||||
|
Out.outP(
|
||||||
|
var.newLine + var.MLG + var.worldName + ": " + var.level_4 + ":"
|
||||||
+ var.newLine);
|
+ var.newLine);
|
||||||
} else if (line.contains("level 5")) { // "Preparing start region for level 5"
|
} else if (line
|
||||||
Out.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_5 + ":"
|
.contains("level 5")) { // "Preparing start region for level 5"
|
||||||
|
Out.outP(
|
||||||
|
var.newLine + var.MLG + var.worldName + ": " + var.level_5 + ":"
|
||||||
+ var.newLine);
|
+ var.newLine);
|
||||||
} else if (line.contains("level 6")) { // "Preparing start region for level 6"
|
} else if (line
|
||||||
Out.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_6 + ":"
|
.contains("level 6")) { // "Preparing start region for level 6"
|
||||||
|
Out.outP(
|
||||||
|
var.newLine + var.MLG + var.worldName + ": " + var.level_6 + ":"
|
||||||
+ var.newLine);
|
+ var.newLine);
|
||||||
} else if (line.contains("level 7")) { // "Preparing start region for level 7"
|
} else if (line
|
||||||
Out.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_7 + ":"
|
.contains("level 7")) { // "Preparing start region for level 7"
|
||||||
|
Out.outP(
|
||||||
|
var.newLine + var.MLG + var.worldName + ": " + var.level_7 + ":"
|
||||||
+ var.newLine);
|
+ var.newLine);
|
||||||
} else if (line.contains("level 8")) { // "Preparing start region for level 8"
|
} else if (line
|
||||||
Out.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_8 + ":"
|
.contains("level 8")) { // "Preparing start region for level 8"
|
||||||
|
Out.outP(
|
||||||
|
var.newLine + var.MLG + var.worldName + ": " + var.level_8 + ":"
|
||||||
+ var.newLine);
|
+ var.newLine);
|
||||||
} else if (line.contains("level 9")) { // "Preparing start region for level 9"
|
} else if (line
|
||||||
Out.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_9 + ":"
|
.contains("level 9")) { // "Preparing start region for level 9"
|
||||||
|
Out.outP(
|
||||||
|
var.newLine + var.MLG + var.worldName + ": " + var.level_9 + ":"
|
||||||
+ var.newLine);
|
+ var.newLine);
|
||||||
} else {
|
} else {
|
||||||
Out.outP(var.newLine + var.MLG + shortLine + var.newLine);
|
Out.outP(var.newLine + var.MLG + shortLine + var.newLine);
|
||||||
}
|
}
|
||||||
} else if (line.contains("server version") || line.contains("Converting map!")) { //TODO: add to .conf
|
} else if (line.contains("server version") || line
|
||||||
|
.contains("Converting map!")) { //TODO: add to .conf
|
||||||
Out.outS(shortLine);
|
Out.outS(shortLine);
|
||||||
|
|
||||||
if (line.contains("server version") && var.MC_Server_Version.isEmpty()) {
|
if (line.contains("server version") && var.MC_Server_Version.isEmpty()) {
|
||||||
@ -196,6 +232,8 @@ public class Server {
|
|||||||
|
|
||||||
if (line.contains(var.doneText)) { // now this is configurable!
|
if (line.contains(var.doneText)) { // now this is configurable!
|
||||||
|
|
||||||
|
serverDoneReceived = true;
|
||||||
|
|
||||||
Out.outP(var.newLine);
|
Out.outP(var.newLine);
|
||||||
Out.outS(line.substring(line.lastIndexOf("]") + 2, line.indexOf("!")));
|
Out.outS(line.substring(line.lastIndexOf("]") + 2, line.indexOf("!")));
|
||||||
if (var.waitSave) {
|
if (var.waitSave) {
|
||||||
@ -263,7 +301,8 @@ public class Server {
|
|||||||
if (line.contains("[WARNING]")) { // If we have a warning, stop...
|
if (line.contains("[WARNING]")) { // If we have a warning, stop...
|
||||||
Out.out("");
|
Out.out("");
|
||||||
Out.out("Warning found: Stopping " + var.PROG_NAME);
|
Out.out("Warning found: Stopping " + var.PROG_NAME);
|
||||||
if (var.verbose == false) { // If verbose is true, we already displayed it.
|
if (var.verbose
|
||||||
|
== false) { // If verbose is true, we already displayed it.
|
||||||
Out.outS(line);
|
Out.outS(line);
|
||||||
}
|
}
|
||||||
Out.out("");
|
Out.out("");
|
||||||
@ -271,7 +310,8 @@ public class Server {
|
|||||||
outputStream.write(saveAll);
|
outputStream.write(saveAll);
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
// OutputStream outputStream = process.getOutputStream();
|
// OutputStream outputStream = process.getOutputStream();
|
||||||
outputStream.write(stop); // if the warning was a fail to bind to port, we may need to write stop twice!
|
outputStream.write(
|
||||||
|
stop); // if the warning was a fail to bind to port, we may need to write stop twice!
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
outputStream.write(stop);
|
outputStream.write(stop);
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
@ -282,7 +322,8 @@ public class Server {
|
|||||||
if (line.contains("[SEVERE]")) { // If we have a severe error, stop...
|
if (line.contains("[SEVERE]")) { // If we have a severe error, stop...
|
||||||
Out.out("");
|
Out.out("");
|
||||||
Out.out("Severe error found: Stopping server.");
|
Out.out("Severe error found: Stopping server.");
|
||||||
if (var.verbose == false) { // If verbose is true, we already displayed it.
|
if (var.verbose
|
||||||
|
== false) { // If verbose is true, we already displayed it.
|
||||||
Out.outS(line);
|
Out.outS(line);
|
||||||
}
|
}
|
||||||
Out.out("");
|
Out.out("");
|
||||||
@ -306,7 +347,8 @@ public class Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warning == true) { // in 1.4.4 we had a issue. tried to write stop twice, but we had closed the stream already. this, and other lines should fix this.
|
if (warning
|
||||||
|
== true) { // in 1.4.4 we had a issue. tried to write stop twice, but we had closed the stream already. this, and other lines should fix this.
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
//outputStream.close();
|
//outputStream.close();
|
||||||
//System.exit(1);
|
//System.exit(1);
|
||||||
@ -317,6 +359,17 @@ public class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// while loop has finished now.
|
// while loop has finished now.
|
||||||
return serverSuccess;
|
// tfw while loop so big you need a comment to see where it ended ~V
|
||||||
|
|
||||||
|
// workaround for Windows not instantly freeing virtmem after exit
|
||||||
|
|
||||||
|
// TODO: Seems broken (not triggering)
|
||||||
|
if (var.postShutdownDelay) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(2500);
|
||||||
|
} catch (InterruptedException ex) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return serverSuccess && serverDoneReceived;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,10 @@ public class var {
|
|||||||
public static final String PROG_NAME = "Minecraft Land Generator";
|
public static final String PROG_NAME = "Minecraft Land Generator";
|
||||||
|
|
||||||
/** Version Number! */
|
/** Version Number! */
|
||||||
public static final String VERSION = "1.7.7";
|
public static final String VERSION = "1.7.8";
|
||||||
|
|
||||||
/** Authors */
|
/** Authors */
|
||||||
public static final String AUTHORS = "Corrodias, Morlok8k, pr0f1x, jaseg, Gallion";
|
public static final String AUTHORS = "Corrodias, Morlok8k, pr0f1x, jaseg, Gallion, VADemon";
|
||||||
|
|
||||||
/** Website */
|
/** Website */
|
||||||
public static final String WEBSITE = "https://sites.google.com/site/minecraftlandgenerator/";
|
public static final String WEBSITE = "https://sites.google.com/site/minecraftlandgenerator/";
|
||||||
@ -185,6 +185,9 @@ public class var {
|
|||||||
/** Beta 1.9 glitch workaround. (not needed unless using beta 1.9) */
|
/** Beta 1.9 glitch workaround. (not needed unless using beta 1.9) */
|
||||||
public static boolean waitSave = false;
|
public static boolean waitSave = false;
|
||||||
|
|
||||||
|
/** Delay shutdown to give OS time to free memory from current application **/
|
||||||
|
public static boolean postShutdownDelay = false;
|
||||||
|
|
||||||
/** Ignores Warnings from the server. Used for compatibility and special cases */
|
/** Ignores Warnings from the server. Used for compatibility and special cases */
|
||||||
public static boolean ignoreWarnings = false;
|
public static boolean ignoreWarnings = false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user