Delete stuff
This commit is contained in:
parent
142cc34060
commit
4993aacfd6
@ -1,18 +1,20 @@
|
|||||||
package morlok8k.MinecraftLandGenerator;
|
package morlok8k.MinecraftLandGenerator;
|
||||||
|
|
||||||
import picocli.CommandLine.Option;
|
import java.nio.file.Path;
|
||||||
import picocli.CommandLine.Parameters;
|
|
||||||
import picocli.CommandLine;
|
import picocli.CommandLine;
|
||||||
import picocli.CommandLine.RunLast;
|
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
import picocli.CommandLine.HelpCommand;
|
import picocli.CommandLine.HelpCommand;
|
||||||
|
import picocli.CommandLine.Option;
|
||||||
|
import picocli.CommandLine.Parameters;
|
||||||
|
import picocli.CommandLine.RunLast;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@Command(name = "mlg", subcommands = {
|
@Command(name = "mlg", subcommands = {
|
||||||
HelpCommand.class})
|
HelpCommand.class})
|
||||||
|
|
||||||
public class CommandLineMain implements Runnable{
|
public class CommandLineMain implements Runnable {
|
||||||
@Option(names = {"-v", "--verbose"}, description = "Be verbose.")
|
@Option(names = { "-v", "--verbose" }, description = "Be verbose.")
|
||||||
private boolean verbose = false;
|
private boolean verbose = false;
|
||||||
|
|
||||||
@Parameters(index = "0", description = "X-coordinate")
|
@Parameters(index = "0", description = "X-coordinate")
|
||||||
@ -33,11 +35,10 @@ public class CommandLineMain implements Runnable{
|
|||||||
@Option(names = {"--y-offset", "-yoff"}, description = "set the Z offset to generate land around")
|
@Option(names = {"--y-offset", "-yoff"}, description = "set the Z offset to generate land around")
|
||||||
private int zOffset = 0;
|
private int zOffset = 0;
|
||||||
|
|
||||||
|
public CommandLineMain() {
|
||||||
|
|
||||||
public CommandLineMain(){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
CommandLine.usage(this, System.err);
|
CommandLine.usage(this, System.err);
|
||||||
|
@ -19,205 +19,14 @@
|
|||||||
|
|
||||||
package morlok8k.MinecraftLandGenerator;
|
package morlok8k.MinecraftLandGenerator;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.joml.Vector3i;
|
import org.joml.Vector3i;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author morlok8k
|
* @author morlok8k
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class FileRead {
|
public class FileRead {
|
||||||
|
|
||||||
/**
|
|
||||||
* @param file
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(Main.class);
|
|
||||||
|
|
||||||
public static ArrayList<Vector3i> readArrayListCoordLog(final String file) {
|
|
||||||
|
|
||||||
|
|
||||||
final ArrayList<Vector3i> Return = new ArrayList<>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
final BufferedReader in = new BufferedReader(new FileReader(new File(file)));
|
|
||||||
String line = "";
|
|
||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
|
||||||
|
|
||||||
line = line.trim();
|
|
||||||
|
|
||||||
int end = line.indexOf('#'); // comments, ignored lines
|
|
||||||
boolean ignoreLine = false;
|
|
||||||
Vector3i c;
|
|
||||||
|
|
||||||
if (end == -1) { // If we have no hash sign, then we read till the end of the line
|
|
||||||
end = line.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (end == 0) { //hash is first char, meaning entire line is a comment
|
|
||||||
ignoreLine = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ignoreLine)) {
|
|
||||||
c = parseString(line.substring(0, end));
|
|
||||||
Return.add(c);
|
|
||||||
} else {
|
|
||||||
if (line.startsWith("##Size:")) { // Potential Resume data.
|
|
||||||
int xx = 0;
|
|
||||||
int zz = 0;
|
|
||||||
|
|
||||||
xx = line.indexOf('X');
|
|
||||||
zz = line.indexOf('Z');
|
|
||||||
|
|
||||||
var.resumeX = Integer.parseInt(line.substring(xx + 1, zz));
|
|
||||||
var.resumeZ = Integer.parseInt(line.substring(zz + 1));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
|
|
||||||
} catch (final FileNotFoundException ex) {
|
|
||||||
log.info("Could not find " + file + ".");
|
|
||||||
return Return;
|
|
||||||
} catch (final IOException ex) {
|
|
||||||
log.error("Could not read " + file + ".");
|
|
||||||
return Return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static void readConf() {
|
|
||||||
//TODO: element comment
|
|
||||||
//String errorMsg = "";
|
|
||||||
|
|
||||||
try {
|
|
||||||
final File config = new File(var.MinecraftLandGeneratorConf);
|
|
||||||
final BufferedReader in = new BufferedReader(new FileReader(config));
|
|
||||||
String line = "";
|
|
||||||
String property = "";
|
|
||||||
String value = "";
|
|
||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
|
||||||
int pos = line.indexOf('=');
|
|
||||||
|
|
||||||
int end = line.lastIndexOf('#'); // comments, ignored lines
|
|
||||||
|
|
||||||
if (end == -1) { // If we have no hash sign, then we read till the end of the line
|
|
||||||
end = line.length();
|
|
||||||
|
|
||||||
}
|
|
||||||
if (end <= (pos + 1)) { // If hash is before the '=', we may have an issue... it should be fine, cause we check for issues next, but lets make sure.
|
|
||||||
end = line.length();
|
|
||||||
pos = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (end == 0) { //hash is first char, meaning entire line is a comment
|
|
||||||
end = line.length();
|
|
||||||
pos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos != -1) {
|
|
||||||
if (line.length() == 0) {
|
|
||||||
property = "";
|
|
||||||
value = "";
|
|
||||||
} else {
|
|
||||||
property = line.substring(0, pos).toLowerCase();
|
|
||||||
value = line.substring(pos + 1, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property.equals("serverpath")) {
|
|
||||||
var.serverPath = value;
|
|
||||||
} else if (property.equals("java")) {
|
|
||||||
var.javaLine = value;
|
|
||||||
} else if (property.equals("done_text")) {
|
|
||||||
var.doneText = value;
|
|
||||||
} else if (property.equals("preparing_text")) {
|
|
||||||
var.preparingText = value;
|
|
||||||
} else if (property.equals("preparing_level")) {
|
|
||||||
var.preparingLevel = value;
|
|
||||||
} else if (property.equals("level-0")) {
|
|
||||||
var.level_0 = value;
|
|
||||||
} else if (property.equals("level-1")) {
|
|
||||||
var.level_1 = value;
|
|
||||||
} else if (property.equals("level-2")) {
|
|
||||||
var.level_2 = value;
|
|
||||||
} else if (property.equals("level-3")) {
|
|
||||||
var.level_3 = value;
|
|
||||||
} else if (property.equals("level-4")) {
|
|
||||||
var.level_4 = value;
|
|
||||||
} else if (property.equals("level-5")) {
|
|
||||||
var.level_5 = value;
|
|
||||||
} else if (property.equals("level-6")) {
|
|
||||||
var.level_6 = value;
|
|
||||||
} else if (property.equals("level-7")) {
|
|
||||||
var.level_7 = value;
|
|
||||||
} else if (property.equals("level-8")) {
|
|
||||||
var.level_8 = value;
|
|
||||||
} else if (property.equals("level-9")) {
|
|
||||||
var.level_9 = value;
|
|
||||||
} else if (property.equals("waitsave")) {
|
|
||||||
if (value.toLowerCase().equals("true")) {
|
|
||||||
var.waitSave = true;
|
|
||||||
} else {
|
|
||||||
var.waitSave = false;
|
|
||||||
}
|
|
||||||
} else if (property.equals("weblaunch")) {
|
|
||||||
if (value.toLowerCase().equals("true")) {
|
|
||||||
var.webLaunch = true;
|
|
||||||
} else {
|
|
||||||
var.webLaunch = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
|
|
||||||
if (var.testing) {
|
|
||||||
log.debug("Test Output: Reading of Config File ");
|
|
||||||
log.debug(" serverPath: " + var.serverPath);
|
|
||||||
log.debug(" javaLine: " + var.javaLine);
|
|
||||||
log.debug(" doneText: " + var.doneText);
|
|
||||||
log.debug(" preparingText: " + var.preparingText);
|
|
||||||
log.debug("preparingLevel: " + var.preparingLevel);
|
|
||||||
log.debug(" level_0: " + var.level_0);
|
|
||||||
log.debug(" level_1: " + var.level_1);
|
|
||||||
log.debug(" level_2: " + var.level_2);
|
|
||||||
log.debug(" level_3: " + var.level_3);
|
|
||||||
log.debug(" level_4: " + var.level_4);
|
|
||||||
log.debug(" level_5: " + var.level_5);
|
|
||||||
log.debug(" level_6: " + var.level_6);
|
|
||||||
log.debug(" level_7: " + var.level_7);
|
|
||||||
log.debug(" level_8: " + var.level_8);
|
|
||||||
log.debug(" level_9: " + var.level_9);
|
|
||||||
log.debug(" waitSave: " + var.waitSave);
|
|
||||||
log.debug(" webLaunch: " + var.webLaunch);
|
|
||||||
}
|
|
||||||
} catch (final FileNotFoundException ex) {
|
|
||||||
log.error("Could not find "
|
|
||||||
+ var.MinecraftLandGeneratorConf
|
|
||||||
+ ". It is recommended that you run the application with the -conf option to create it.");
|
|
||||||
return;
|
|
||||||
} catch (final IOException ex) {
|
|
||||||
log.error("Could not read " + var.MinecraftLandGeneratorConf + ".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector3i parseString(String StringOfCoords) {
|
public static Vector3i parseString(String StringOfCoords) {
|
||||||
StringOfCoords = StringOfCoords.trim();
|
StringOfCoords = StringOfCoords.trim();
|
||||||
|
|
||||||
@ -231,13 +40,15 @@ public class FileRead {
|
|||||||
end = StringOfCoords.indexOf(")");
|
end = StringOfCoords.indexOf(")");
|
||||||
String[] coordshort = StringOfCoords.substring(start, end).split(",");
|
String[] coordshort = StringOfCoords.substring(start, end).split(",");
|
||||||
if ((start != -1) && (end != -1)) {
|
if ((start != -1) && (end != -1)) {
|
||||||
return new Vector3i(Integer.valueOf(coordshort[0]), 64, Integer.valueOf(coordshort[2]));
|
return new Vector3i(Integer.valueOf(coordshort[0]), 64,
|
||||||
|
Integer.valueOf(coordshort[2]));
|
||||||
} else {
|
} else {
|
||||||
return new Vector3i(0, 0, 0);
|
return new Vector3i(0, 0, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return new Vector3i(Integer.valueOf(coordlong[0]), Integer.valueOf(coordlong[1]), Integer.valueOf(coordlong[2]));
|
return new Vector3i(Integer.valueOf(coordlong[0]), Integer.valueOf(coordlong[1]),
|
||||||
|
Integer.valueOf(coordlong[2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
package morlok8k.MinecraftLandGenerator;
|
package morlok8k.MinecraftLandGenerator;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -32,12 +31,10 @@ import java.util.Iterator;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import morlok8k.MinecraftLandGenerator.GUI.MLG_GUI;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.joml.Vector3i;
|
import org.joml.Vector3i;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Corrodias, Morlok8k, pr0f1x
|
* @author Corrodias, Morlok8k, pr0f1x
|
||||||
*/
|
*/
|
||||||
@ -52,91 +49,12 @@ public class Main {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
* the command line arguments
|
* the command line arguments
|
||||||
*/
|
*/
|
||||||
private static Log log = LogFactory.getLog(Main.class);
|
private static Log log = LogFactory.getLog(Main.class);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Main.runCLI();
|
||||||
var.startTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
var.originalArgs = args; // we may potentially remove some args later, but we keep a record of the original for the log file.
|
|
||||||
|
|
||||||
// This is really just here for debugging...
|
|
||||||
// I plan on adding more asserts later, but for now, this will do.
|
|
||||||
// to enable this, run:
|
|
||||||
// java -enableassertions -jar MinecraftLandGenerator.jar
|
|
||||||
assert var.assertsEnabled = true; // Intentional side-effect!!! (This may cause a Warning, which is safe to ignore: "Possible accidental assignment in place of a comparison. A condition expression should not be reduced to an assignment")
|
|
||||||
if (var.assertsEnabled) {
|
|
||||||
log.info("assertsEnabled: " + var.assertsEnabled);
|
|
||||||
var.verbose = true;
|
|
||||||
log.info("Verbose mode forced!");
|
|
||||||
var.testing = true;
|
|
||||||
log.info("Debug mode forced!");
|
|
||||||
var.dontWait = true;
|
|
||||||
log.info("-nowait mode forced!");
|
|
||||||
log.info("");
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean GUI = false; // GUI needs to be true to run in graphical mode
|
|
||||||
boolean NOGUI = false; // NOGUI is a flag that finds reasons to not use a graphical mode.
|
|
||||||
|
|
||||||
if (args.length != 0) { // if args are present, then we assume we want NOGUI
|
|
||||||
NOGUI = true; // if no args are present, we will attempt GUI
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] argsNOGUI = new String[args.length];
|
|
||||||
argsNOGUI = args;
|
|
||||||
argsNOGUI = StringArrayParse.Parse(argsNOGUI, "nogui"); //parse out "nogui"
|
|
||||||
if (!(args.equals(argsNOGUI))) { //do the freshly parsed args match the original?
|
|
||||||
args = argsNOGUI; //use the freshly parsed args for everything else now...
|
|
||||||
NOGUI = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//MLG_GUI Choosing code...
|
|
||||||
if ((!NOGUI) && (!java.awt.GraphicsEnvironment.isHeadless())) {
|
|
||||||
GUI = true;
|
|
||||||
if (var.testing) {
|
|
||||||
log.info("MLG_GUI: This is a graphical enviroment.");
|
|
||||||
}
|
|
||||||
|
|
||||||
//////
|
|
||||||
GUI = false; // forcing GUI to be false for now, because I don't have the MLG_GUI code ready yet!
|
|
||||||
//////
|
|
||||||
|
|
||||||
} else {
|
|
||||||
GUI = false; // No GUI for us today...
|
|
||||||
if (var.testing) {
|
|
||||||
log.info("MLG_GUI: Command Line Only!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GUI) { //GUI
|
|
||||||
// Launch MLG_GUI
|
|
||||||
|
|
||||||
EventQueue.invokeLater(new Runnable() {
|
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
final MLG_GUI window = new MLG_GUI();
|
|
||||||
window.frmMLG_GUI.setVisible(true);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} else { //No GUI
|
|
||||||
// Finally, Lets Start MLG!
|
|
||||||
|
|
||||||
var.UsingGUI = false;
|
|
||||||
var.args = args;
|
|
||||||
Main.runCLI();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -281,7 +199,8 @@ public class Main {
|
|||||||
log.info("Centering land generation on [" + var.xOffset + ", " + var.zOffset
|
log.info("Centering land generation on [" + var.xOffset + ", " + var.zOffset
|
||||||
+ "] due to switches.");
|
+ "] due to switches.");
|
||||||
} else {
|
} else {
|
||||||
log.info("Centering land generation on [" + var.xOffset + ", " + var.zOffset + "]\n");
|
log.info("Centering land generation on [" + var.xOffset + ", " + var.zOffset
|
||||||
|
+ "]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
double xLoops, zLoops;
|
double xLoops, zLoops;
|
||||||
@ -329,7 +248,7 @@ public class Main {
|
|||||||
if (xLoops > 3) {
|
if (xLoops > 3) {
|
||||||
xLoops = xLoops + 1;
|
xLoops = xLoops + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zLoops > 3) {
|
if (zLoops > 3) {
|
||||||
zLoops = zLoops + 1;
|
zLoops = zLoops + 1;
|
||||||
}
|
}
|
||||||
@ -340,7 +259,8 @@ public class Main {
|
|||||||
log.info("Estimated Total Spawn Points: " + totalIterations);
|
log.info("Estimated Total Spawn Points: " + totalIterations);
|
||||||
|
|
||||||
if (totalIterations > Integer.MAX_VALUE) {
|
if (totalIterations > Integer.MAX_VALUE) {
|
||||||
log.error("TOO BIG! Please reduce the world size. World Size can't be larger than 17609200 x 17609200"); //or 17794560 using -i384
|
log.error(
|
||||||
|
"TOO BIG! Please reduce the world size. World Size can't be larger than 17609200 x 17609200"); //or 17794560 using -i384
|
||||||
backupLevel.delete();
|
backupLevel.delete();
|
||||||
log.info("Removed backup file.");
|
log.info("Removed backup file.");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
@ -357,7 +277,8 @@ public class Main {
|
|||||||
launchList = new ArrayList<>((int) totalIterations);
|
launchList = new ArrayList<>((int) totalIterations);
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
log.error("TOO BIG! Your computer can't handle such a large map. The size is dependant on 32/64 bit and Memory.");
|
log.error(
|
||||||
|
"TOO BIG! Your computer can't handle such a large map. The size is dependant on 32/64 bit and Memory.");
|
||||||
backupLevel.delete();
|
backupLevel.delete();
|
||||||
log.info("Removed backup file.");
|
log.info("Removed backup file.");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
@ -392,22 +313,20 @@ public class Main {
|
|||||||
{ // Middle of Loop
|
{ // Middle of Loop
|
||||||
|
|
||||||
if (currentIteration % 10000000 == 0) { //for long calculations, we output an update every 10,000,000 points
|
if (currentIteration % 10000000 == 0) { //for long calculations, we output an update every 10,000,000 points
|
||||||
String percentDone =
|
String percentDone = Double.toString(
|
||||||
Double.toString((((double) currentIteration) / totalIterations) * 100);
|
(((double) currentIteration) / totalIterations) * 100);
|
||||||
final int percentIndex =
|
final int percentIndex =
|
||||||
((percentDone.indexOf(".") + 3) > percentDone.length())
|
((percentDone.indexOf(".") + 3) > percentDone.length())
|
||||||
? percentDone.length() : (percentDone.indexOf(".") + 3); //fix index on numbers like 12.3
|
? percentDone.length() : (percentDone.indexOf(".") + 3); //fix index on numbers like 12.3
|
||||||
percentDone =
|
percentDone = percentDone.substring(0, (percentDone.indexOf(".") == -1
|
||||||
percentDone.substring(0, (percentDone.indexOf(".") == -1
|
? percentDone.length() : percentIndex)); //Trim output, unless whole number
|
||||||
? percentDone.length() : percentIndex)); //Trim output, unless whole number
|
|
||||||
log.info("Calculated: " + currentIteration + "/" + totalIterations
|
log.info("Calculated: " + currentIteration + "/" + totalIterations
|
||||||
+ " spawn points. (" + percentDone + "% Done)");
|
+ " spawn points. (" + percentDone + "% Done)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// add Coordinates to arraylist here
|
// add Coordinates to arraylist here
|
||||||
final Vector3i tempCoords =
|
final Vector3i tempCoords = new Vector3i((int) currentX + var.xOffset, 64,
|
||||||
new Vector3i((int) currentX + var.xOffset, 64, (int) currentZ
|
(int) currentZ + var.zOffset);
|
||||||
+ var.zOffset);
|
|
||||||
launchList.add(tempCoords);
|
launchList.add(tempCoords);
|
||||||
|
|
||||||
// Write the current Coordinates to log file!
|
// Write the current Coordinates to log file!
|
||||||
@ -421,8 +340,8 @@ public class Main {
|
|||||||
} // End of the Middle of Loop
|
} // End of the Middle of Loop
|
||||||
|
|
||||||
if (curZloops == 1) { // We are at the North edge. We have special code for the North edge, so we need to change currentZ to be normal again.
|
if (curZloops == 1) { // We are at the North edge. We have special code for the North edge, so we need to change currentZ to be normal again.
|
||||||
currentZ =
|
currentZ = (long) ((Math.ceil((((0 - zRangeAdj) / 2) / var.increment)))
|
||||||
(long) ((Math.ceil((((0 - zRangeAdj) / 2) / var.increment))) * var.increment);
|
* var.increment);
|
||||||
}
|
}
|
||||||
if (southEdgeReached) {
|
if (southEdgeReached) {
|
||||||
currentZ = (long) zRangeAdj; // We reached the South edge, so we make sure that we exit the "for loop", bypassing the "1152 bug"
|
currentZ = (long) zRangeAdj; // We reached the South edge, so we make sure that we exit the "for loop", bypassing the "1152 bug"
|
||||||
@ -431,8 +350,8 @@ public class Main {
|
|||||||
} // End Z
|
} // End Z
|
||||||
curZloops = 0;
|
curZloops = 0;
|
||||||
if (curXloops == 1) { // We are at the West edge. We have special code for the West edge, so we need to change currentX to be normal again.
|
if (curXloops == 1) { // We are at the West edge. We have special code for the West edge, so we need to change currentX to be normal again.
|
||||||
currentX =
|
currentX = (long) ((Math.ceil((((0 - xRangeAdj) / 2) / var.increment)))
|
||||||
(long) ((Math.ceil((((0 - xRangeAdj) / 2) / var.increment))) * var.increment);
|
* var.increment);
|
||||||
}
|
}
|
||||||
if (eastEdgeReached) {
|
if (eastEdgeReached) {
|
||||||
currentX = (long) xRangeAdj; // We reached the East edge, so we make sure that we exit the "for loop", bypassing the "1152 bug"
|
currentX = (long) xRangeAdj; // We reached the East edge, so we make sure that we exit the "for loop", bypassing the "1152 bug"
|
||||||
@ -472,13 +391,10 @@ public class Main {
|
|||||||
|
|
||||||
String percentDone =
|
String percentDone =
|
||||||
Double.toString((((double) currentIteration - 1) / totalIterations) * 100);
|
Double.toString((((double) currentIteration - 1) / totalIterations) * 100);
|
||||||
final int percentIndex =
|
final int percentIndex = ((percentDone.indexOf(".") + 3) > percentDone.length())
|
||||||
((percentDone.indexOf(".") + 3) > percentDone.length()) ? percentDone
|
? percentDone.length() : (percentDone.indexOf(".") + 3); //fix index on numbers like 12.3
|
||||||
.length() : (percentDone.indexOf(".") + 3); //fix index on numbers like 12.3
|
percentDone = percentDone.substring(0,
|
||||||
percentDone =
|
(percentDone.indexOf(".") == -1 ? percentDone.length() : percentIndex)); //Trim output, unless whole number
|
||||||
percentDone.substring(0,
|
|
||||||
(percentDone.indexOf(".") == -1 ? percentDone.length()
|
|
||||||
: percentIndex)); //Trim output, unless whole number
|
|
||||||
|
|
||||||
log.info("Setting spawn to [X,Y,Z]: " + xyz + " (" + currentIteration + " of "
|
log.info("Setting spawn to [X,Y,Z]: " + xyz + " (" + currentIteration + " of "
|
||||||
+ totalIterations + ") " + percentDone + "% Done"); // Time Remaining estimate
|
+ totalIterations + ") " + percentDone + "% Done"); // Time Remaining estimate
|
||||||
@ -489,7 +405,8 @@ public class Main {
|
|||||||
differenceTime =
|
differenceTime =
|
||||||
(timeTracking - generationStartTimeTracking) / (currentIteration + 1); // Updated. we now count all runs, instead of the last 4.
|
(timeTracking - generationStartTimeTracking) / (currentIteration + 1); // Updated. we now count all runs, instead of the last 4.
|
||||||
differenceTime *= 1 + (totalIterations - currentIteration); // this should provide a more accurate result.
|
differenceTime *= 1 + (totalIterations - currentIteration); // this should provide a more accurate result.
|
||||||
log.info("Estimated time remaining: " + String.format("%02d:%02d", (differenceTime / 1000) / 60, (differenceTime / 1000) % 60)); // I've noticed it gets pretty accurate after about 8 launches!
|
log.info("Estimated time remaining: " + String.format("%02d:%02d",
|
||||||
|
(differenceTime / 1000) / 60, (differenceTime / 1000) % 60)); // I've noticed it gets pretty accurate after about 8 launches!
|
||||||
|
|
||||||
// Set the spawn point
|
// Set the spawn point
|
||||||
SpawnPoint.setSpawn(serverLevel, xyz);
|
SpawnPoint.setSpawn(serverLevel, xyz);
|
||||||
@ -526,10 +443,10 @@ public class Main {
|
|||||||
Misc.copyFile(backupLevel, serverLevel);
|
Misc.copyFile(backupLevel, serverLevel);
|
||||||
backupLevel.delete();
|
backupLevel.delete();
|
||||||
log.info("Restored original level.dat.");
|
log.info("Restored original level.dat.");
|
||||||
long completeIn =var.startTime - System.currentTimeMillis();
|
long completeIn = var.startTime - System.currentTimeMillis();
|
||||||
log.info("Generation complete in: "
|
log.info("Generation complete in: " + String.format("%02d:%02d",
|
||||||
+ String.format("%02d:%02d", (completeIn / 1000) / 60, (completeIn / 1000) % 60));
|
(completeIn / 1000) / 60, (completeIn / 1000) % 60));
|
||||||
// Time.waitTenSec(false);
|
// Time.waitTenSec(false);
|
||||||
|
|
||||||
if (var.webLaunch) { //if webLaunch is already false, don't check for these things
|
if (var.webLaunch) { //if webLaunch is already false, don't check for these things
|
||||||
if (java.awt.GraphicsEnvironment.isHeadless()) {
|
if (java.awt.GraphicsEnvironment.isHeadless()) {
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
#######################################################################
|
|
||||||
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE #
|
|
||||||
# Version 2, December 2004 #
|
|
||||||
# #
|
|
||||||
# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> #
|
|
||||||
# #
|
|
||||||
# Everyone is permitted to copy and distribute verbatim or modified #
|
|
||||||
# copies of this license document, and changing it is allowed as long #
|
|
||||||
# as the name is changed. #
|
|
||||||
# #
|
|
||||||
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE #
|
|
||||||
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION #
|
|
||||||
# #
|
|
||||||
# 0. You just DO WHAT THE FUCK YOU WANT TO. #
|
|
||||||
# #
|
|
||||||
#######################################################################
|
|
||||||
*/
|
|
||||||
|
|
||||||
package morlok8k.MinecraftLandGenerator;
|
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
|
||||||
import java.lang.management.RuntimeMXBean;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author morlok8k
|
|
||||||
*/
|
|
||||||
public class SelfAware {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String JVMinfo() {
|
|
||||||
|
|
||||||
String Return = "";
|
|
||||||
|
|
||||||
final RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
|
|
||||||
final List<String> aList = RuntimemxBean.getInputArguments();
|
|
||||||
|
|
||||||
for (int i = 0; i < aList.size(); i++) {
|
|
||||||
Return = Return + (aList.get(i)) + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
Return = Return.trim();
|
|
||||||
|
|
||||||
Return =
|
|
||||||
"Launch info: Java: " + System.getProperty("java.vm.name") + " "
|
|
||||||
+ System.getProperty("java.version") + " OS: "
|
|
||||||
+ System.getProperty("os.name") + " " + System.getProperty("os.version")
|
|
||||||
+ " " + System.getProperty("os.arch") + " "
|
|
||||||
+ System.getProperty("sun.desktop") + var.newLine + "# JVM: " + " JAR: "
|
|
||||||
+ System.getProperty("sun.java.command") + " ARGS: ";
|
|
||||||
|
|
||||||
for (int i = 0; i < var.originalArgs.length; i++) {
|
|
||||||
Return = Return + (var.originalArgs[i]) + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
Return = Return.trim();
|
|
||||||
return Return;
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,13 +7,13 @@
|
|||||||
|
|
||||||
package morlok8k.MinecraftLandGenerator;
|
package morlok8k.MinecraftLandGenerator;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -21,306 +21,41 @@ import java.io.OutputStream;
|
|||||||
*/
|
*/
|
||||||
public class Server {
|
public class Server {
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the process in the given ProcessBuilder, monitors its output for a "[INFO] Done!" message, and sends it a "stop\r\n" message. One message is printed to the console before launching and
|
|
||||||
* one is printed to the console when the Done! message is detected. If "verbose" is true, the process's output will also be printed to the console.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @throws IOException
|
|
||||||
* @author Corrodias, Morlok8k
|
|
||||||
*/
|
|
||||||
private static Log log = LogFactory.getLog(Main.class);
|
private static Log log = LogFactory.getLog(Main.class);
|
||||||
|
|
||||||
protected static boolean runMinecraft() throws IOException {
|
/**
|
||||||
|
* Starts the process in the given ProcessBuilder, monitors its output for a "Done" message, and sends it a "stop" message.
|
||||||
|
* If "verbose" is true, the process's output will also be printed to the console.
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws InterruptedException
|
||||||
|
* @author Corrodias, Morlok8k, piegames
|
||||||
|
*/
|
||||||
|
protected static void runMinecraft() throws IOException, InterruptedException {
|
||||||
|
log.info("Starting server.");
|
||||||
|
final Process process = var.minecraft.start();
|
||||||
|
|
||||||
if (var.verbose) {
|
final BufferedReader pOut =
|
||||||
log.info("Starting server.");
|
new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
}
|
for (String line = pOut.readLine(); line != null; line = pOut.readLine()) {
|
||||||
boolean serverSuccess = true;
|
line = line.trim();
|
||||||
boolean warning = false;
|
if (log.isDebugEnabled()) log.debug(line);
|
||||||
boolean warningsWeCanIgnore = false;
|
|
||||||
final boolean ignoreWarningsOriginal = var.ignoreWarnings;
|
|
||||||
|
|
||||||
// monitor output and print to console where required.
|
if (line.contains("Done")) {
|
||||||
// STOP the server when it's done.
|
PrintStream out = new PrintStream(process.getOutputStream());
|
||||||
|
|
||||||
if (var.alternate) { // Alternate - a replication (slightly stripped down) of MLG 1.3.0's code. simplest code possible.
|
log.info("Stopping server... ");
|
||||||
log.info("Alternate Launch");
|
out.println("save-all");
|
||||||
final Process process = var.minecraft.start();
|
out.flush();
|
||||||
|
out.println("stop");
|
||||||
final byte[] saveAll = { 's', 'a', 'v', 'e', '-', 'a', 'l', 'l', '\r', '\n' };
|
out.flush();
|
||||||
final byte[] stop = { 's', 't', 'o', 'p', '\r', '\n' };
|
|
||||||
|
|
||||||
// monitor output and print to console where required.
|
|
||||||
// STOP the server when it's done.
|
|
||||||
final BufferedReader pOut =
|
|
||||||
new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
||||||
String line;
|
|
||||||
while ((line = pOut.readLine()) != null) { // readLine() returns null when the process exits
|
|
||||||
|
|
||||||
line = line.trim();
|
|
||||||
|
|
||||||
System.out.println(line);
|
|
||||||
if (line.contains(var.doneText)) { // EDITED By Morlok8k for Minecraft 1.3+ Beta
|
|
||||||
final OutputStream outputStream = process.getOutputStream();
|
|
||||||
|
|
||||||
log.info("Stopping server... (Please Wait...)");
|
|
||||||
outputStream.write(saveAll);
|
|
||||||
outputStream.flush();
|
|
||||||
outputStream.write(stop);
|
|
||||||
outputStream.flush();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// End while loop
|
|
||||||
|
|
||||||
} else { // start minecraft server normally!
|
|
||||||
final Process process = var.minecraft.start();
|
|
||||||
if (var.verbose) {
|
|
||||||
log.info("Started Server.");
|
|
||||||
}
|
|
||||||
final BufferedReader pOut =
|
|
||||||
new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
||||||
if (var.verbose) {
|
|
||||||
log.info("Accessing Server Output...");
|
|
||||||
}
|
|
||||||
|
|
||||||
String line = null;
|
|
||||||
String shortLine = null;
|
|
||||||
String outTmp = "";
|
|
||||||
String outTmp2 = null;
|
|
||||||
|
|
||||||
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!
|
|
||||||
|
|
||||||
final byte[] saveAll = { 's', 'a', 'v', 'e', '-', 'a', 'l', 'l', '\r', '\n' };
|
|
||||||
|
|
||||||
boolean prepTextFirst = true;
|
|
||||||
|
|
||||||
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)
|
|
||||||
// just so it gets a line ending after the % output finishes
|
|
||||||
while ((line = pOut.readLine()) != null) { // readLine() returns null when the process exits
|
|
||||||
|
|
||||||
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.
|
|
||||||
if (posBracket != -1) {
|
|
||||||
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.
|
|
||||||
} else {
|
|
||||||
shortLine = line.substring(posBracket + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
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.
|
|
||||||
} // added this check to remove warning, as i didn't want to suppress all null warnings for runMinecraft
|
|
||||||
|
|
||||||
} else {
|
|
||||||
shortLine = line;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (var.verbose) {
|
|
||||||
log.info(shortLine);
|
|
||||||
//} else if (line.toLowerCase().contains("saving")) { //this was just clutter
|
|
||||||
// Main.outS(shortLine);
|
|
||||||
} else if (line.contains(var.preparingText) || line.contains("Converting...")) {
|
|
||||||
if (line.contains("Converting...")) {
|
|
||||||
convertedMapFormattingFlag = true;
|
|
||||||
}
|
|
||||||
outTmp2 = line.substring(line.length() - 3, line.length());
|
|
||||||
outTmp2 = outTmp2.trim(); //we are removing extra spaces here
|
|
||||||
|
|
||||||
//if (outTmp.equals(outTmp2)) {
|
|
||||||
//instead of printing the same number, we add another dot
|
|
||||||
//Main.outP(".");
|
|
||||||
//} else {
|
|
||||||
outTmp = outTmp2;
|
|
||||||
|
|
||||||
if (prepTextFirst) {
|
|
||||||
log.info(var.MLG + outTmp + "...");
|
|
||||||
prepTextFirst = false;
|
|
||||||
} else {
|
|
||||||
//Main.outP(" " + outTmp + "...");
|
|
||||||
log.info("\r" + var.MLG + outTmp + "..."); //here we use \r to go back to the previous line, and rewrite it
|
|
||||||
}
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
} else if (line.contains(var.preparingLevel)) {
|
|
||||||
prepTextFirst = true;
|
|
||||||
|
|
||||||
if (convertedMapFormattingFlag == true) {
|
|
||||||
log.info(var.newLine);
|
|
||||||
convertedMapFormattingFlag = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.contains("level 0")) { // "Preparing start region for level 0"
|
|
||||||
log.info(var.MLG + var.worldName + ": " + var.level_0 + ":" + var.newLine);
|
|
||||||
} else if (line.contains("level 1")) { // "Preparing start region for level 1"
|
|
||||||
log.info(var.newLine + var.MLG + var.worldName + ": " + var.level_1 + ":"
|
|
||||||
+ var.newLine);
|
|
||||||
} else if (line.contains("level 2")) { // "Preparing start region for level 2"
|
|
||||||
log.info(var.newLine + var.MLG + var.worldName + ": " + var.level_2 + ":"
|
|
||||||
+ var.newLine);
|
|
||||||
} else if (line.contains("level 3")) { // "Preparing start region for level 3"
|
|
||||||
log.info(var.newLine + var.MLG + var.worldName + ": " + var.level_3 + ":"
|
|
||||||
+ var.newLine);
|
|
||||||
} else if (line.contains("level 4")) { // "Preparing start region for level 4"
|
|
||||||
log.info(var.newLine + var.MLG + var.worldName + ": " + var.level_4 + ":"
|
|
||||||
+ var.newLine);
|
|
||||||
} else if (line.contains("level 5")) { // "Preparing start region for level 5"
|
|
||||||
log.info(var.newLine + var.MLG + var.worldName + ": " + var.level_5 + ":"
|
|
||||||
+ var.newLine);
|
|
||||||
} else if (line.contains("level 6")) { // "Preparing start region for level 6"
|
|
||||||
log.info(var.newLine + var.MLG + var.worldName + ": " + var.level_6 + ":"
|
|
||||||
+ var.newLine);
|
|
||||||
} else if (line.contains("level 7")) { // "Preparing start region for level 7"
|
|
||||||
log.info(var.newLine + var.MLG + var.worldName + ": " + var.level_7 + ":"
|
|
||||||
+ var.newLine);
|
|
||||||
} else if (line.contains("level 8")) { // "Preparing start region for level 8"
|
|
||||||
log.info(var.newLine + var.MLG + var.worldName + ": " + var.level_8 + ":"
|
|
||||||
+ var.newLine);
|
|
||||||
} else if (line.contains("level 9")) { // "Preparing start region for level 9"
|
|
||||||
log.info(var.newLine + var.MLG + var.worldName + ": " + var.level_9 + ":"
|
|
||||||
+ var.newLine);
|
|
||||||
} else {
|
|
||||||
log.info(var.newLine + var.MLG + shortLine + var.newLine);
|
|
||||||
}
|
|
||||||
} else if (line.contains("server version") || line.contains("Converting map!")) { //TODO: add to .conf
|
|
||||||
log.info(shortLine);
|
|
||||||
|
|
||||||
if (line.contains("server version") && var.MC_Server_Version.isEmpty()) {
|
|
||||||
// if server version, save string to variable, for use in arraylist save file.
|
|
||||||
var.MC_Server_Version = shortLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.contains(var.doneText)) { // now this is configurable!
|
|
||||||
|
|
||||||
log.info(var.newLine);
|
|
||||||
log.info(line.substring(line.lastIndexOf("]") + 2, line.indexOf("!")));
|
|
||||||
if (var.waitSave) {
|
|
||||||
log.info("Waiting 30 seconds to save...");
|
|
||||||
|
|
||||||
int count = 1;
|
|
||||||
while (count <= 30) {
|
|
||||||
log.info(".");
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (final InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
log.info("");
|
|
||||||
}
|
|
||||||
log.info("Saving server data...");
|
|
||||||
outputStream.write(saveAll);
|
|
||||||
outputStream.flush();
|
|
||||||
|
|
||||||
log.info("Stopping server... (Please Wait...)");
|
|
||||||
// OutputStream outputStream = process.getOutputStream();
|
|
||||||
outputStream.write(stop);
|
|
||||||
outputStream.flush();
|
|
||||||
// outputStream.close();
|
|
||||||
|
|
||||||
if (var.waitSave) {
|
|
||||||
log.info("Waiting 10 seconds to save.");
|
|
||||||
int count = 1;
|
|
||||||
while (count <= 10) {
|
|
||||||
log.info(".");
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (final InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
log.info("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Here we want to ignore the most common warning: "Can't keep up!"
|
|
||||||
if (line.contains("Can't keep up!")) { //TODO: add to .conf
|
|
||||||
warningsWeCanIgnore = true; //[WARNING] Can't keep up! Did the system time change, or is the server overloaded?
|
|
||||||
var.ignoreWarnings = true;
|
|
||||||
} else if (line.contains("[WARNING] To start the server with more ram")) {
|
|
||||||
if (var.verbose == false) { // If verbose is true, we already displayed it.
|
|
||||||
log.info(line);
|
|
||||||
}
|
|
||||||
warningsWeCanIgnore = true; //we can safely ignore this...
|
|
||||||
var.ignoreWarnings = true;
|
|
||||||
} else if (line.contains("Error occurred during initialization of VM")
|
|
||||||
|| line.contains("Could not reserve enough space for object heap")) {
|
|
||||||
if (var.verbose == false) { // If verbose is true, we already displayed it.
|
|
||||||
log.info("[Java Error] " + line);
|
|
||||||
}
|
|
||||||
warning = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (var.ignoreWarnings == false) {
|
|
||||||
if (line.contains("[WARNING]")) { // If we have a warning, stop...
|
|
||||||
log.info("");
|
|
||||||
log.info("Warning found: Stopping " + var.PROG_NAME);
|
|
||||||
if (var.verbose == false) { // If verbose is true, we already displayed it.
|
|
||||||
log.info(line);
|
|
||||||
}
|
|
||||||
log.info("");
|
|
||||||
log.info("Forcing Save...");
|
|
||||||
outputStream.write(saveAll);
|
|
||||||
outputStream.flush();
|
|
||||||
// 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.flush();
|
|
||||||
outputStream.write(stop);
|
|
||||||
outputStream.flush();
|
|
||||||
// outputStream.close();
|
|
||||||
warning = true;
|
|
||||||
// System.exit(1);
|
|
||||||
}
|
|
||||||
if (line.contains("[SEVERE]")) { // If we have a severe error, stop...
|
|
||||||
log.info("");
|
|
||||||
log.info("Severe error found: Stopping server.");
|
|
||||||
if (var.verbose == false) { // If verbose is true, we already displayed it.
|
|
||||||
log.info(line);
|
|
||||||
}
|
|
||||||
log.info("");
|
|
||||||
log.info("Forcing Save...");
|
|
||||||
outputStream.write(saveAll);
|
|
||||||
outputStream.flush();
|
|
||||||
// OutputStream outputStream = process.getOutputStream();
|
|
||||||
outputStream.write(stop);
|
|
||||||
outputStream.flush();
|
|
||||||
outputStream.write(stop); // sometimes we need to do stop twice...
|
|
||||||
outputStream.flush();
|
|
||||||
// outputStream.close();
|
|
||||||
warning = true;
|
|
||||||
// System.exit(1);
|
|
||||||
// Quit!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (warningsWeCanIgnore) {
|
|
||||||
var.ignoreWarnings = ignoreWarningsOriginal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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.close();
|
|
||||||
//System.exit(1);
|
|
||||||
serverSuccess = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
outputStream.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// while loop has finished now.
|
/* The process should have stopped by now. */
|
||||||
return serverSuccess;
|
int exit = process.waitFor();
|
||||||
|
if (exit != 0)
|
||||||
|
log.warn("Process stopped with non-zero exit code (" + exit + ")");
|
||||||
|
else log.info("Stopped server");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,14 @@
|
|||||||
|
|
||||||
package morlok8k.MinecraftLandGenerator;
|
package morlok8k.MinecraftLandGenerator;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author morlok8k
|
* @author morlok8k
|
||||||
@ -58,9 +58,8 @@ public class Setup {
|
|||||||
|
|
||||||
//---------- Verify server.properties
|
//---------- Verify server.properties
|
||||||
try {
|
try {
|
||||||
serverPropertiesFile =
|
serverPropertiesFile = new BufferedReader(new FileReader(
|
||||||
new BufferedReader(new FileReader(new File(var.serverPath + var.fileSeparator
|
new File(var.serverPath + var.fileSeparator + "server.properties")));
|
||||||
+ "server.properties")));
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Could not open the server.properties file.");
|
log.error("Could not open the server.properties file.");
|
||||||
return true;
|
return true;
|
||||||
@ -116,7 +115,8 @@ public class Setup {
|
|||||||
|
|
||||||
if (levelDat.exists() && levelDat.isFile()) {
|
if (levelDat.exists() && levelDat.isFile()) {
|
||||||
if (backupLevel.exists()) {
|
if (backupLevel.exists()) {
|
||||||
log.error("There is a level_backup.dat file left over from a previous attempt that failed.");
|
log.error(
|
||||||
|
"There is a level_backup.dat file left over from a previous attempt that failed.");
|
||||||
log.info("Resuming...");
|
log.info("Resuming...");
|
||||||
|
|
||||||
//use resume data
|
//use resume data
|
||||||
@ -141,16 +141,14 @@ public class Setup {
|
|||||||
} else {
|
} else {
|
||||||
/*FileNotFoundException fileException =
|
/*FileNotFoundException fileException =
|
||||||
new FileNotFoundException("The currently configured world does not exist.");*/
|
new FileNotFoundException("The currently configured world does not exist.");*/
|
||||||
log.error("The currently configured world does not exist! Launching the server once to create it...");
|
log.error(
|
||||||
|
"The currently configured world does not exist! Launching the server once to create it...");
|
||||||
try {
|
try {
|
||||||
var.minecraft = new ProcessBuilder(var.javaLine.split("\\s")); // is this always going to work? i don't know. (most likely yes)
|
var.minecraft = new ProcessBuilder(var.javaLine.split("\\s")); // is this always going to work? i don't know. (most likely yes)
|
||||||
var.minecraft.directory(new File(var.serverPath));
|
var.minecraft.directory(new File(var.serverPath));
|
||||||
var.minecraft.redirectErrorStream(true);
|
var.minecraft.redirectErrorStream(true);
|
||||||
if (!(Server.runMinecraft())) {
|
Server.runMinecraft();
|
||||||
log.error("Huh oh! Something went wrong with the server! Exiting...");
|
} catch (IOException | InterruptedException e) {
|
||||||
System.exit(1); // we got a warning or severe error
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
log.error("World created! Starting world generation...");
|
log.error("World created! Starting world generation...");
|
||||||
|
@ -19,16 +19,15 @@
|
|||||||
|
|
||||||
package morlok8k.MinecraftLandGenerator;
|
package morlok8k.MinecraftLandGenerator;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Date;
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -40,26 +39,6 @@ import java.util.Date;
|
|||||||
public class Startup {
|
public class Startup {
|
||||||
private static Log log = LogFactory.getLog(Main.class);
|
private static Log log = LogFactory.getLog(Main.class);
|
||||||
|
|
||||||
public static void initialStart() {
|
|
||||||
|
|
||||||
// Lets get the date, and our BuildID
|
|
||||||
var.date = new Date();
|
|
||||||
Update.readBuildID();
|
|
||||||
|
|
||||||
// The following displays no matter what happens, so we needed this date stuff to happen first.
|
|
||||||
|
|
||||||
log.info(var.PROG_NAME + " version " + var.VERSION);
|
|
||||||
log.info("BuildID: (" + var.MLG_Last_Modified_Date.getTime() + ")"); // instead of dateformatting the buildid, we return the raw Long number.
|
|
||||||
// thus different timezones wont display a different buildID
|
|
||||||
log.info("This version was last modified on "
|
|
||||||
+ var.dateFormat.format(var.MLG_Last_Modified_Date));
|
|
||||||
log.info("");
|
|
||||||
log.info("Uses a Minecraft server to generate square land of a specified size.");
|
|
||||||
log.info("");
|
|
||||||
log.info("");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* CLI only: Reads arguments from command line
|
* CLI only: Reads arguments from command line
|
||||||
@ -269,7 +248,8 @@ public class Startup {
|
|||||||
var.zOffset = Integer.valueOf(var.args[i + 2].substring(2));
|
var.zOffset = Integer.valueOf(var.args[i + 2].substring(2));
|
||||||
log.info("Notice: Z Offset: " + var.zOffset);
|
log.info("Notice: Z Offset: " + var.zOffset);
|
||||||
if (nextSwitch.startsWith("-y")) {
|
if (nextSwitch.startsWith("-y")) {
|
||||||
log.info("Notice: MLG now uses Z instead of Y. Please use the -z switch instead");
|
log.info(
|
||||||
|
"Notice: MLG now uses Z instead of Y. Please use the -z switch instead");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -284,47 +264,4 @@ public class Startup {
|
|||||||
|
|
||||||
return false; // success!
|
return false; // success!
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean confFile() {
|
|
||||||
FileRead.readConf();
|
|
||||||
|
|
||||||
boolean oldConf = false; // This next section checks to see if we have a old configuration file (or none!)
|
|
||||||
|
|
||||||
if ((var.serverPath == null) || (var.javaLine == null)) { // MLG 1.2 Check for a valid .conf file.
|
|
||||||
log.error(var.MinecraftLandGeneratorConf
|
|
||||||
+ " does not contain all required properties. Making New File!"); // Please recreate it by running this application with -conf.
|
|
||||||
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// We no longer quit. We generate a new one with defaults.
|
|
||||||
|
|
||||||
var.javaLine = var.defaultJavaLine;
|
|
||||||
var.serverPath = ".";
|
|
||||||
oldConf = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (var.doneText == null) { // MLG 1.4.0
|
|
||||||
oldConf = true;
|
|
||||||
} else if (var.preparingText == null) { // MLG 1.4.0
|
|
||||||
oldConf = true;
|
|
||||||
} else if (var.preparingLevel == null) { // MLG 1.4.5 / 1.5.0
|
|
||||||
oldConf = true;
|
|
||||||
} else if (var.level_1 == null) { // MLG 1.4.5 / 1.5.0
|
|
||||||
oldConf = true;
|
|
||||||
} else if (var.level_0 == null) { // MLG 1.5.1 / 1.6.0
|
|
||||||
oldConf = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldConf) {
|
|
||||||
log.error("Old Version of " + var.MinecraftLandGeneratorConf + " found. Updating...");
|
|
||||||
|
|
||||||
FileWrite.saveConf(false); //old conf
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return false; // success!
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user