more refactoring and cleaning up

This commit is contained in:
Morlok8k 2012-09-10 23:28:31 -07:00
parent 4fe1099a28
commit e534d3cc75
9 changed files with 403 additions and 369 deletions

View File

@ -29,9 +29,6 @@ public class Coordinates {
int x = 0, y = 0, z = 0; int x = 0, y = 0, z = 0;
//TODO: add validity checks:
//TODO: add short version... (Y = 64)
int start = 0, end = 0, firstComma = 0, secComma = 0; int start = 0, end = 0, firstComma = 0, secComma = 0;
String sX = "", sY = "", sZ = ""; String sX = "", sY = "", sZ = "";
boolean shortMode = false, notCoords = false; boolean shortMode = false, notCoords = false;
@ -43,7 +40,7 @@ public class Coordinates {
start = StringOfCoords.indexOf("("); start = StringOfCoords.indexOf("(");
end = StringOfCoords.indexOf(")"); end = StringOfCoords.indexOf(")");
if ((start != -1) || (end != -1)) { if ((start != -1) && (end != -1)) {
shortMode = true; shortMode = true;
} else { } else {
notCoords = true; notCoords = true;
@ -87,7 +84,7 @@ public class Coordinates {
} }
/** /**
* Parses a Coordinates object from a String. Leading and trailing garbage is ignored (FIXME). * Parses a Coordinates object from a String. Leading and trailing garbage is ignored.
* *
* @param stringOfCoords * @param stringOfCoords
* A short- or long-form coordinate string as described at the two toString() methods * A short- or long-form coordinate string as described at the two toString() methods
@ -96,6 +93,18 @@ public class Coordinates {
public static Coordinates parseStringRegEx(String stringOfCoords) { public static Coordinates parseStringRegEx(String stringOfCoords) {
int X = 0, Y = 0, Z = 0; int X = 0, Y = 0, Z = 0;
boolean matched = false; boolean matched = false;
int start = stringOfCoords.indexOf("["), end = stringOfCoords.indexOf("]");
if ((start == -1) || (end == -1)) {
start = stringOfCoords.indexOf("(");
end = stringOfCoords.indexOf(")");
}
if ((start != -1) && (end != -1)) {
stringOfCoords = stringOfCoords.substring(start, end + 1); // Leading and trailing garbage is ignored
}
final Matcher shortForm = final Matcher shortForm =
Pattern.compile("\\((-?\\d+),(-?\\d+)\\)").matcher(stringOfCoords); Pattern.compile("\\((-?\\d+),(-?\\d+)\\)").matcher(stringOfCoords);
final Matcher normalForm = final Matcher normalForm =

View File

@ -5,15 +5,12 @@ import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
/**
* http://www.roseindia.net/java/example/java/io/java-append-to-file.shtml <br>
* Append To File - Java Tutorial
*/
public class FileWrite { public class FileWrite {
public static final String newLine = var.newLine;
/** /**
* http://www.roseindia.net/java/example/java/io/java-append-to-file.shtml <br>
* Append To File - Java Tutorial
*
* @param file * @param file
* @param appendTxt * @param appendTxt
*/ */

View File

@ -46,5 +46,4 @@ public class MD5 {
} }
} }
} }
} }

View File

@ -20,20 +20,10 @@ import java.util.logging.Logger;
*/ */
public class Main { public class Main {
private static int MinecraftServerChunkPlayerCache = 625; //You see this number when you first launch the server in GUI mode, after the world is loaded, but before anyone has connected. public static int xRange = 0;
private static int increment = (int) (Math.sqrt(MinecraftServerChunkPlayerCache) * 16) - 20; //private int increment = 380; public static int zRange = 0;
public static Integer zOffset = null;
private int xRange = 0; public static Integer xOffset = null;
private int zRange = 0;
private Integer xOffset = null;
private Integer zOffset = null;
private boolean alternate = false;
private static Boolean recheckFlag = false;
private static long startTime = 0L;
private static boolean assertsEnabled = false; //debugging use... use java -ea -jar MinecraftlandGenerator.jar...
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
// REMINDER: Because I always forget/mix up languages: // // REMINDER: Because I always forget/mix up languages: //
@ -42,34 +32,23 @@ public class Main {
// public/private shows/hides between classes // // public/private shows/hides between classes //
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
/**
* Outputs a formatted string to System.err as a line.
*
* @param str
* String to display and format
* @author Morlok8k
*/
public static void err(final String str) {
System.err.println(var.MLGe + str);
}
/** /**
* @param args * @param args
* the command line arguments * the command line arguments
*/ */
public static void main(String[] args) { public static void main(String[] args) {
startTime = System.currentTimeMillis(); var.startTime = System.currentTimeMillis();
var.originalArgs = args; 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... // This is really just here for debugging...
// I plan on adding more asserts later, but for now, this will do. // I plan on adding more asserts later, but for now, this will do.
// to enable this, run: // to enable this, run:
// java -enableassertions -jar MinecraftLandGenerator.jar // java -enableassertions -jar MinecraftLandGenerator.jar
assert 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") 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 (assertsEnabled) { if (var.assertsEnabled) {
outD("assertsEnabled: " + assertsEnabled); outD("assertsEnabled: " + var.assertsEnabled);
var.verbose = true; var.verbose = true;
outD("Verbose mode forced!"); outD("Verbose mode forced!");
var.testing = true; var.testing = true;
@ -113,7 +92,7 @@ public class Main {
/* /*
try { try {
(new Main()).runGUI(args); Main()).runGUI(args;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -121,7 +100,7 @@ public class Main {
} else { //No GUI } else { //No GUI
// Finally, Lets Start MLG! // Finally, Lets Start MLG!
(new Main()).runCLI(args); // this avoids "static" compiling issues. Main.runCLI(args);
} }
} }
@ -170,6 +149,17 @@ public class Main {
System.out.println("[Server] " + str); System.out.println("[Server] " + str);
} }
/**
* Outputs a formatted string to System.err as a line.
*
* @param str
* String to display and format
* @author Morlok8k
*/
public static void err(final String str) {
System.err.println(var.MLGe + str);
}
/** /**
* Start MinecraftLandGenerator (Command Line Interface) * Start MinecraftLandGenerator (Command Line Interface)
* *
@ -177,7 +167,7 @@ public class Main {
* @param args * @param args
* *
*/ */
private void runCLI(String[] args) { private static void runCLI(String[] args) {
// Lets get the date, and our BuildID // Lets get the date, and our BuildID
var.date = new Date(); var.date = new Date();
@ -211,7 +201,7 @@ public class Main {
out("Notice: Not waiting for anything..."); out("Notice: Not waiting for anything...");
} }
if (args.length == 0) { //we didnt find a an X and Z size, so lets ask for one. if (args.length == 0) { //we didn't find a an X and Z size, so lets ask for one.
out("Please Enter the size of world you want. Example: X:1000 Z:1000"); out("Please Enter the size of world you want. Example: X:1000 Z:1000");
outP(var.MLG + "X:"); outP(var.MLG + "X:");
xRange = Input_CLI.getInt("X:"); xRange = Input_CLI.getInt("X:");
@ -296,14 +286,14 @@ public class Main {
String line; String line;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
if (line.contains("###RECHECK###")) { if (line.contains("###RECHECK###")) {
recheckFlag = !recheckFlag; var.recheckFlag = !var.recheckFlag;
} else { } else {
DownloadFile.downloadFile(line, true); DownloadFile.downloadFile(line, true);
} }
} }
in.close(); in.close();
if (recheckFlag == true) { if (var.recheckFlag == true) { // the first line is always the location of this file. the second is the recheck flag, if we want to.
try { try {
recheckMD5 = MD5.fileMD5(config.toString()); recheckMD5 = MD5.fileMD5(config.toString());
} catch (final NoSuchAlgorithmException e) { } catch (final NoSuchAlgorithmException e) {
@ -316,7 +306,7 @@ public class Main {
String line_recheck; String line_recheck;
while ((line_recheck = in_recheck.readLine()) != null) { while ((line_recheck = in_recheck.readLine()) != null) {
if (line_recheck.contains("###RECHECK###")) { if (line_recheck.contains("###RECHECK###")) {
recheckFlag = !recheckFlag; var.recheckFlag = !var.recheckFlag;
} else { } else {
DownloadFile.downloadFile(line_recheck, true); DownloadFile.downloadFile(line_recheck, true);
} }
@ -410,7 +400,7 @@ public class Main {
} }
var.verbose = false; // Verifing that these vars are false var.verbose = false; // Verifing that these vars are false
alternate = false; // before changing them... var.alternate = false; // before changing them...
// This is embarrassing. Don't look. // This is embarrassing. Don't look.
try { try {
@ -421,15 +411,15 @@ public class Main {
out("Notice: Verbose Mode"); out("Notice: Verbose Mode");
} else if (nextSwitch.startsWith("-i")) { } else if (nextSwitch.startsWith("-i")) {
increment = Integer.parseInt(args[i + 2].substring(2)); var.increment = Integer.parseInt(args[i + 2].substring(2));
out("Notice: Non-Default Increment: " + increment); out("Notice: Non-Default Increment: " + var.increment);
} else if (nextSwitch.startsWith("-w")) { } else if (nextSwitch.startsWith("-w")) {
var.ignoreWarnings = true; var.ignoreWarnings = true;
out("Notice: Warnings from Server are Ignored"); out("Notice: Warnings from Server are Ignored");
} else if (nextSwitch.equals("-alt") || nextSwitch.equals("-a")) { } else if (nextSwitch.equals("-alt") || nextSwitch.equals("-a")) {
alternate = true; var.alternate = true;
out("Notice: Using Alternate Launching"); out("Notice: Using Alternate Launching");
} else if (nextSwitch.startsWith("-x")) { } else if (nextSwitch.startsWith("-x")) {
@ -494,7 +484,7 @@ public class Main {
// PROCESSING // PROCESSING
// ===================================================================== // =====================================================================
out("Processing world \"" + var.worldPath + "\", in " + increment out("Processing world \"" + var.worldPath + "\", in " + var.increment
+ " block increments, with: " + var.javaLine); + " block increments, with: " + var.javaLine);
// out( MLG + "Processing \"" + worldName + "\"..."); // out( MLG + "Processing \"" + worldName + "\"...");
@ -511,7 +501,7 @@ public class Main {
final long generationStartTimeTracking = System.currentTimeMillis(); //Start of time remaining calculations. final long generationStartTimeTracking = System.currentTimeMillis(); //Start of time remaining calculations.
final boolean serverLaunch = Server.runMinecraft(alternate); final boolean serverLaunch = Server.runMinecraft();
if (!(serverLaunch)) { if (!(serverLaunch)) {
System.exit(1); // we got a warning or severe error System.exit(1); // we got a warning or severe error
@ -579,15 +569,15 @@ public class Main {
// run mlg on remaining list of spawn points. // run mlg on remaining list of spawn points.
// X // X
xLoops = ((double) xRange / (double) increment); //How many loops do we need? xLoops = ((double) xRange / (double) var.increment); //How many loops do we need?
xLoops = Math.ceil(xLoops); //round up to find out! xLoops = Math.ceil(xLoops); //round up to find out!
xRangeAdj = (int) (xLoops * increment); xRangeAdj = (int) (xLoops * var.increment);
xLoops = xLoops + 1; xLoops = xLoops + 1;
// Z // Z
zLoops = ((double) zRange / (double) increment); //How many loops do we need? zLoops = ((double) zRange / (double) var.increment); //How many loops do we need?
zLoops = Math.ceil(zLoops); //round up to find out! zLoops = Math.ceil(zLoops); //round up to find out!
zRangeAdj = (int) (zLoops * increment); zRangeAdj = (int) (zLoops * var.increment);
zLoops = zLoops + 1; zLoops = zLoops + 1;
out("Calculating Spawn Points..."); out("Calculating Spawn Points...");
@ -601,22 +591,22 @@ public class Main {
final ArrayList<Coordinates> launchList = new ArrayList<Coordinates>(totalIterations); final ArrayList<Coordinates> launchList = new ArrayList<Coordinates>(totalIterations);
for (int currentX = 0; currentX <= (xRangeAdj / 2); currentX += increment) { for (int currentX = 0; currentX <= (xRangeAdj / 2); currentX += var.increment) {
curXloops++; curXloops++;
if (curXloops == 1) { if (curXloops == 1) {
currentX = (((0 - xRange) / 2) + (increment / 2) + 16); currentX = (((0 - xRange) / 2) + (var.increment / 2) + 16);
} else if (curXloops == xLoops) { } else if (curXloops == xLoops) {
currentX = (xRange / 2) - (increment / 2); currentX = (xRange / 2) - (var.increment / 2);
} }
for (int currentZ = 0; currentZ <= (zRangeAdj / 2); currentZ += increment) { for (int currentZ = 0; currentZ <= (zRangeAdj / 2); currentZ += var.increment) {
currentIteration++; currentIteration++;
curZloops++; curZloops++;
if (curZloops == 1) { if (curZloops == 1) {
currentZ = (((0 - zRange) / 2) + (increment / 2) + 16); currentZ = (((0 - zRange) / 2) + (var.increment / 2) + 16);
} else if (curZloops == zLoops) { } else if (curZloops == zLoops) {
currentZ = (zRange / 2) - (increment / 2); currentZ = (zRange / 2) - (var.increment / 2);
} }
{ {
@ -632,13 +622,14 @@ public class Main {
if (curZloops == 1) { if (curZloops == 1) {
currentZ = currentZ =
(int) ((Math.ceil((((0 - zRangeAdj) / 2) / increment))) * increment); (int) ((Math.ceil((((0 - zRangeAdj) / 2) / var.increment))) * var.increment);
} }
} }
curZloops = 0; curZloops = 0;
if (curXloops == 1) { if (curXloops == 1) {
currentX = (int) ((Math.ceil((((0 - xRangeAdj) / 2) / increment))) * increment); currentX =
(int) ((Math.ceil((((0 - xRangeAdj) / 2) / var.increment))) * var.increment);
} }
} }
@ -692,7 +683,7 @@ public class Main {
// Launch the server // Launch the server
boolean serverSuccess = false; boolean serverSuccess = false;
serverSuccess = Server.runMinecraft(alternate); serverSuccess = Server.runMinecraft();
out(""); out("");
//////// End server launch code //////// End server launch code
@ -718,7 +709,7 @@ public class Main {
out("Restored original level.dat."); out("Restored original level.dat.");
out("Generation complete in: " out("Generation complete in: "
+ Time.displayTime(startTime, System.currentTimeMillis())); + Time.displayTime(var.startTime, System.currentTimeMillis()));
Time.waitTenSec(false); Time.waitTenSec(false);
//TODO: add if's //TODO: add if's

View File

@ -42,8 +42,7 @@ public class Misc {
* @return * @return
*/ */
static boolean printSpawn() { static boolean printSpawn() {
// ugh, sorry, this is an ugly hack, but it's a last-minute feature. this is a lot of duplicated code. // ugh, sorry, this is an ugly hack
// - Fixed by Morlok8k
FileRead.readConf(); FileRead.readConf();
WorldVerify.verifyWorld(); WorldVerify.verifyWorld();

View File

@ -2,11 +2,6 @@ package morlok8k.MinecraftLandGenerator;
public class Readme_and_HelpInfo { public class Readme_and_HelpInfo {
static String newLine = var.newLine;
static String MLGFileNameShort = var.MLGFileNameShort;
static String MinecraftLandGeneratorConf = var.MinecraftLandGeneratorConf;
static String defaultReadmeFile = var.defaultReadmeFile;
/** /**
* Saves a Readme file. * Saves a Readme file.
* *
@ -17,203 +12,204 @@ public class Readme_and_HelpInfo {
public static void readMe(String readmeFile) { public static void readMe(String readmeFile) {
if ((readmeFile == "") || (readmeFile == null)) { if ((readmeFile == "") || (readmeFile == null)) {
readmeFile = defaultReadmeFile; readmeFile = var.defaultReadmeFile;
} }
final String MLG_Last_Modified_MDY = final String MLG_Last_Modified_MDY = var.dateFormat_MDY.format(var.MLG_Last_Modified_Date);
var.dateFormat_MDY.format(var.MLG_Last_Modified_Date);
final String PROG_NAME = var.PROG_NAME; final String PROG_NAME = var.PROG_NAME;
final String VERSION = var.VERSION; final String VERSION = var.VERSION;
String showHelpSTR = ""; String showHelpSTR = "";
String ReadMeText = ""; String ReadMeText = "";
String VersionInfo = ""; String VersionInfo = "";
String n = var.newLine;
//@formatter:off //@formatter:off
ReadMeText = PROG_NAME + " version " + VERSION + newLine ReadMeText = PROG_NAME + " version " + VERSION + n
+ newLine + n
+ "Updated " + MLG_Last_Modified_MDY + newLine + "Updated " + MLG_Last_Modified_MDY + n
+ "(BuildID: " + var.MLG_Last_Modified_Date.getTime() + ")" + newLine + "(BuildID: " + var.MLG_Last_Modified_Date.getTime() + ")" + n
+ newLine + n
+ "Original Code by Corrodias November 2010" + newLine + "Original Code by Corrodias November 2010" + n
+ "Enhanced Code by Morlok8k Feb. 2011 to Now (or at least to " + MLG_Last_Modified_MDY + "!)" + newLine + "Enhanced Code by Morlok8k Feb. 2011 to Now (or at least to " + MLG_Last_Modified_MDY + "!)" + n
+ "Additional Code by pr0f1x October 2011" + newLine + "Additional Code by pr0f1x October 2011" + n
+ newLine + n
+ "Website: https://sites.google.com/site/minecraftlandgenerator/" + newLine + "Website: https://sites.google.com/site/minecraftlandgenerator/" + n
+ "Forum: http://www.minecraftforum.net/topic/187737-minecraft-land-generator/" + newLine + "Forum: http://www.minecraftforum.net/topic/187737-minecraft-land-generator/" + n
+ "Source: https://github.com/Morlok8k/MinecraftLandGenerator" + newLine + "Source: https://github.com/Morlok8k/MinecraftLandGenerator" + n
+ newLine + n
+ "-----------------------------------------------" + newLine + "-----------------------------------------------" + n
+ newLine + n
+ "This program lets you generate an area of land with your Minecraft SMP server (and is prossibly future-proof for newer versions). You set up your java command line and minecraft server paths in the MinecraftLandGenerator.conf file, set up the server's server.properties file with the name of the world you wish to use, and then run this program." + newLine + "This program lets you generate an area of land with your Minecraft SMP server (and is prossibly future-proof for newer versions). You set up your java command line and minecraft server paths in the MinecraftLandGenerator.conf file, set up the server's server.properties file with the name of the world you wish to use, and then run this program." + n
+ "When a Minecraft server is launched, it automatically generates chunks within a square area of 25x25 chunks (400x400 blocks), centered on the current spawn point (formally 20x20 chunks, 320x320 blocks). When provided X and Z ranges as arguments, this program will launch the server repeatedly, editing the level.dat file between sessions, to generate large amounts of land without players having to explore them. The generated land will have about the X and Z ranges as requested by the arguments, though it will not be exact due to the spawn point typically not on the border of a chunk. (Because of this, MLG by default adds a slight overlap with each pass - 380x380 blocks) You can use the -x and -z switches to override the spawn offset and center the land generation on a different point." + newLine + "When a Minecraft server is launched, it automatically generates chunks within a square area of 25x25 chunks (400x400 blocks), centered on the current spawn point (formally 20x20 chunks, 320x320 blocks). When provided X and Z ranges as arguments, this program will launch the server repeatedly, editing the level.dat file between sessions, to generate large amounts of land without players having to explore them. The generated land will have about the X and Z ranges as requested by the arguments, though it will not be exact due to the spawn point typically not on the border of a chunk. (Because of this, MLG by default adds a slight overlap with each pass - 380x380 blocks) You can use the -x and -z switches to override the spawn offset and center the land generation on a different point." + n
+ "The program makes a backup of level.dat as level_backup.dat before editing, and restores the backup at the end. In the event that a level_backup.dat file already exists, the program will refuse to proceed, leaving the user to determine why the level_backup.dat file exists and whether they would rather restore it or delete it, which must be done manually." + newLine + "The program makes a backup of level.dat as level_backup.dat before editing, and restores the backup at the end. In the event that a level_backup.dat file already exists, the program will refuse to proceed, leaving the user to determine why the level_backup.dat file exists and whether they would rather restore it or delete it, which must be done manually." + n
+ newLine + n
+ "This program is public domain, and the source code is included in the .jar file. (If accidently missing, like in 1.3.0 and 1.4.0, it is always available at Github.)" + newLine + "This program is public domain, and the source code is included in the .jar file. (If accidently missing, like in 1.3.0 and 1.4.0, it is always available at Github.)" + n
+ "The JNLP library is included (inside the .jar). It is not public domain. Its license is included, as LICENSE.TXT." + newLine + "The JNLP library is included (inside the .jar). It is not public domain. Its license is included, as LICENSE.TXT." + n
+ "It is also available at: http://jnbt.sourceforge.net/" + newLine + "It is also available at: http://jnbt.sourceforge.net/" + n
+ newLine + n
+ "The \"unescape\" method/function is also not Public Domain. Its License is the W3C\u00A9 Software License, and located here: http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231" + "The \"unescape\" method/function is also not Public Domain. Its License is the W3C\u00A9 Software License, and located here: http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231"
+ newLine + n
+ "Other Public Domain code has been used in this program, and references to sources are included in the comments of " + PROG_NAME + "'s source code." + "Other Public Domain code has been used in this program, and references to sources are included in the comments of " + PROG_NAME + "'s source code."
+ newLine + n
+ "-----------------------------------------------" + newLine + "-----------------------------------------------" + n
+ newLine; + n;
//@formatter:on //@formatter:on
showHelpSTR = showHelp(false); //stored as a string for easier manipulation in the future showHelpSTR = showHelp(false); //stored as a string for easier manipulation in the future
//@formatter:off //@formatter:off
VersionInfo = newLine VersionInfo = n
+ "-----------------------------------------------" + newLine + "-----------------------------------------------" + n
+ newLine + n
+ "Version History:" + newLine + "Version History:" + n
+ "Morlok8k:" + newLine + "Morlok8k:" + n
+ "1.7.1" + newLine + "1.7.1" + n
+ "- TODO: %done tweak" + newLine //TODO + "- Major Code Refactoring" + n
+ "- TODO: outliers issue / region fix" + newLine + "- TODO: %done tweak" + n //TODO
+ "- TODO: 16/512 block selecting" + newLine + "- TODO: outliers issue / region fix" + n
+ "- TODO: remember that the outside is 400, not 380!" + newLine + "- TODO: 16/512 block selecting" + n
+ "- TODO: always calculate from orgin, just adjust outer box to match" + newLine + "- TODO: remember that the outside is 400, not 380!" + n
+ "- TODO: recaculate existing coords with new code" + newLine + "- TODO: always calculate from orgin, just adjust outer box to match" + n
+ "- TODO: change 380 to 384?" + newLine //TODO + "- TODO: recaculate existing coords with new code" + n
+ "1.7.0" + newLine + "- TODO: change 380 to 384?" + n //TODO
+ "- Major Code Optimization" + newLine + "1.7.0" + n
+ "- Drastically reduced the amount of time it takes for MLG to expand a world after it has already done so before!" + newLine + "- Major Code Optimization" + n
+ " (To do this, I rewrote the Main loop of the program, and add my own Coordinate object)" + newLine + "- Drastically reduced the amount of time it takes for MLG to expand a world after it has already done so before!" + n
+ "- Added Resume Functionality" + newLine + " (To do this, I rewrote the Main loop of the program, and add my own Coordinate object)" + n
+ "- Updated Time Output yet again." + newLine + "- Added Resume Functionality" + n
+ "- Made xx% output nicer by rewriting previous existing line." + newLine + "- Updated Time Output yet again." + n
+ "- Misc. Tweaks" + newLine + "- Made xx% output nicer by rewriting previous existing line." + n
+ "- Misc. Additions" + newLine + "- Misc. Tweaks" + n
+ "1.6.3" + newLine + "- Misc. Additions" + n
+ "- Minor Code Optimization" + newLine + "1.6.3" + n
+ "- Finely got on the ball and added the JNBT source and everything (as an internal .zip) to be completely faithful to his license" + newLine + "- Minor Code Optimization" + n
+ "- Also adding script files internally in the .jar for archive (or offline) purposes. (Manual Extract needed for use)" + newLine + "- Finely got on the ball and added the JNBT source and everything (as an internal .zip) to be completely faithful to his license" + n
+ "- Modified output of MLG slightly to show whats the server and whats MLG. (I may do more with this later.)" + newLine + "- Also adding script files internally in the .jar for archive (or offline) purposes. (Manual Extract needed for use)" + n
+ "1.6.2" + newLine + "- Modified output of MLG slightly to show whats the server and whats MLG. (I may do more with this later.)" + n
+ "- Major Code Optimization" + newLine + "1.6.2" + n
+ "- Updated Time Output again. Now says \"1 Minute\" instead of \"1 Minutes\"." + newLine + "- Major Code Optimization" + n
+ "- Updated Location Code - the center of the square is now truely centered, and it trys to get as close to the given size as possible." + newLine + "- Updated Time Output again. Now says \"1 Minute\" instead of \"1 Minutes\"." + n
+ "- Added \"-nowait\" and its shorter version \"-n\"" + newLine + "- Updated Location Code - the center of the square is now truely centered, and it trys to get as close to the given size as possible." + n
+ "- Added currently non-functional RCON code. Will try to make functional in the future." + newLine + "- Added \"-nowait\" and its shorter version \"-n\"" + n
+ newLine + "- Added currently non-functional RCON code. Will try to make functional in the future." + n
+ "1.6.11" + newLine + n
+ "- Removed End-of-Generation ASCII-Graphic - It didn't really fit with MLG." + newLine + "1.6.11" + n
+ "- Updated Time Output." + newLine + "- Removed End-of-Generation ASCII-Graphic - It didn't really fit with MLG." + n
+ "- Changed estimated time remaining to count all runs, not just the last four." + newLine + "- Updated Time Output." + n
+ "- Added the time it took to complete at the end of generation." + newLine + "- Changed estimated time remaining to count all runs, not just the last four." + n
+ newLine + "- Added the time it took to complete at the end of generation." + n
+ "1.6.1" + newLine + n
+ "- Added some modifications for scripting (Mainly for a new Initial setup script)" + newLine + "1.6.1" + n
+ "- Changed MLG's Y to Z. Now it matches Minecraft. Y in the game is Height." + newLine + "- Added some modifications for scripting (Mainly for a new Initial setup script)" + n
+ "- Renamed -y switch to -z. MLG will remain backwards compatible if you use the old -y switch." + newLine + "- Changed MLG's Y to Z. Now it matches Minecraft. Y in the game is Height." + n
+ "- Updated -printspawn to show X,Y,Z" + newLine + "- Renamed -y switch to -z. MLG will remain backwards compatible if you use the old -y switch." + n
+ "- Added End-of-Generation ASCII-Graphic" + newLine + "- Updated -printspawn to show X,Y,Z" + n
+ "- Slightly altered some text output" + newLine + "- Added End-of-Generation ASCII-Graphic" + n
+ newLine + "- Slightly altered some text output" + n
+ "1.6.05" + newLine + n
+ "- MLG displays if the server is converting the Map format, when not in verbose mode. (McRegion -> Anvil, or Chunk-File -> McRegion)" + newLine + "1.6.05" + n
+ "- Minor fixes/edits/typos" + newLine + "- MLG displays if the server is converting the Map format, when not in verbose mode. (McRegion -> Anvil, or Chunk-File -> McRegion)" + n
+ "- Minor fixes/edits/typos" + n
+ "- Added link to new MLG website to readme file" + "- Added link to new MLG website to readme file"
+ newLine + n
+ "1.6.03" + newLine + "1.6.03" + n
+ "- added decoding of escape characters of URL's (so a space is a \" \" and not \"%20\")" + newLine + "- added decoding of escape characters of URL's (so a space is a \" \" and not \"%20\")" + n
+ "- added \"-downloadlist [list]\" where [list] is a text file with URL's on each line" + newLine + "- added \"-downloadlist [list]\" where [list] is a text file with URL's on each line" + n
+ newLine + n
+ "1.6.02" + newLine + "1.6.02" + n
+ "- small fix on caculating md5sum where old version didnt pad out to 32chars with zeros on the left side" + "- small fix on caculating md5sum where old version didnt pad out to 32chars with zeros on the left side"
+ "- quick Archive intergity fix after injecting source code into .jar after it compiled." + "- quick Archive intergity fix after injecting source code into .jar after it compiled."
+ "- no new functionality, md5 issue doesnt affect -update on old versions." + "- no new functionality, md5 issue doesnt affect -update on old versions."
+ newLine + n
+ "1.6.0" + newLine + "1.6.0" + n
+ "- NOW DOES NOT NEED ANY SCRIPT FILES!" + newLine + "- NOW DOES NOT NEED ANY SCRIPT FILES!" + n
+ "- Added the ability to download files from the internet" + newLine + "- Added the ability to download files from the internet" + n
+ "- Added a switch to download any file off the internet, if needed (useless for most people, but included it in case I wanted it in the future.)" + newLine + "- Added a switch to download any file off the internet, if needed (useless for most people, but included it in case I wanted it in the future.)" + n
+ "- Added the ability to check what version the .jar is. (Using MD5 hashes, timestamps, and the BuildID file)" + newLine + "- Added the ability to check what version the .jar is. (Using MD5 hashes, timestamps, and the BuildID file)" + n
+ "- Added \"-update\" to download new versions of MLG directly from github." + newLine + "- Added \"-update\" to download new versions of MLG directly from github." + n
+ "- Updated estimated time. Now shows up on loop 2+ instead of loop 4+." + newLine + "- Updated estimated time. Now shows up on loop 2+ instead of loop 4+." + n
+ "- Standard % output of the Server should look nicer now." + newLine + "- Standard % output of the Server should look nicer now." + n
+ "- Code Refactoring" + newLine + "- Code Refactoring" + n
+ "- Code Formatting" + newLine + "- Code Formatting" + n
+ "- Code Optimization" + newLine + "- Code Optimization" + n
+ "- Duplicate sections of code have been turned into Methods/\"Functions\"" + newLine + "- Duplicate sections of code have been turned into Methods/\"Functions\"" + n
+ newLine + n
+ "1.5.1" + newLine + "1.5.1" + n
+ "- pr0f1x: Added the \"save-all\" command to be sent to the server before shutting it down." + newLine + "- pr0f1x: Added the \"save-all\" command to be sent to the server before shutting it down." + n
+ "- pr0f1x: Added a 40 second wait before shutting down." + newLine + "- pr0f1x: Added a 40 second wait before shutting down." + n
+ "- Morlok8k: Made 40 second wait optional." + newLine + "- Morlok8k: Made 40 second wait optional." + n
+ "- Morlok8k: Changed the Dimensions code. (I had assumed it would be DIM-1, DIM-2, etc. but it turned out to be DIM-1 and DIM1. Change reflects Server output of \"Level n\")" + newLine + "- Morlok8k: Changed the Dimensions code. (I had assumed it would be DIM-1, DIM-2, etc. but it turned out to be DIM-1 and DIM1. Change reflects Server output of \"Level n\")" + n
+ "- Morlok8k: Config file is automatically updated to reflect these changes." + newLine + "- Morlok8k: Config file is automatically updated to reflect these changes." + n
+ "- Morlok8k: Cleaned up code." + newLine + "- Morlok8k: Cleaned up code." + n
+ newLine + n
+ "1.5.0" + newLine + "1.5.0" + n
+ "- Supports Server Beta 1.6.4 (& hopefully future versions as well, while remaining backward compatible.)" + newLine + "- Supports Server Beta 1.6.4 (& hopefully future versions as well, while remaining backward compatible.)" + n
+ "- Added \"-a\",\"-alt\" to use alternate method (a slightly simplier version of 1.3.0's code - pure verbose only)" + newLine + "- Added \"-a\",\"-alt\" to use alternate method (a slightly simplier version of 1.3.0's code - pure verbose only)" + n
+ "- Added world specific output for 9 dimensions (DIM-1 is the Nether, DIM-2 through DIM-9 dont exist yet, but if and when they do, you can configure it's text). (\"Level 0\", the default world, is displayed as the worlds name)" + newLine + "- Added world specific output for 9 dimensions (DIM-1 is the Nether, DIM-2 through DIM-9 dont exist yet, but if and when they do, you can configure it's text). (\"Level 0\", the default world, is displayed as the worlds name)" + n
+ "- Updated Config File for these Dimensions." + newLine + "- Updated Config File for these Dimensions." + n
+ "- Reads and outputs the Seed to the output. (If you had used text for the Seed, Minecraft converts it into a number. This outputs the number.)" + newLine + "- Reads and outputs the Seed to the output. (If you had used text for the Seed, Minecraft converts it into a number. This outputs the number.)" + n
+ "- Changed the default 300 blocks to 380. The server now makes a 400x400 square block terrain instead of 320x320. Thus it is faster because there are less loops. To use the old way, use \"-i300\"" + newLine + "- Changed the default 300 blocks to 380. The server now makes a 400x400 square block terrain instead of 320x320. Thus it is faster because there are less loops. To use the old way, use \"-i300\"" + n
+ "- Added total Percentage done (technically, it displays the % done once the server finishes...)" + newLine + "- Added total Percentage done (technically, it displays the % done once the server finishes...)" + n
+ "- Added debugging output vars of conf file (disabled - need to re-compile source to activate)" + newLine + "- Added debugging output vars of conf file (disabled - need to re-compile source to activate)" + n
+ newLine + n
+ "\t\t+ (the goal is to have MLG be configureable, so it can work on any version of the server, past or present.)" + newLine + "\t\t+ (the goal is to have MLG be configureable, so it can work on any version of the server, past or present.)" + n
+ newLine + n
+ "*** 1.4.5 (pre 1.5.0) ***" + newLine + "*** 1.4.5 (pre 1.5.0) ***" + n
+ "- sorry! I shouldn't release untested code..." + newLine + "- sorry! I shouldn't release untested code..." + n
+ "*************************" + newLine + "*************************" + n
+ newLine + n
+ "1.4.4" + newLine + "1.4.4" + n
+ "- Added ablilty to ignore [WARNING] and [SEVERE] errors with \"-w\"" + newLine + "- Added ablilty to ignore [WARNING] and [SEVERE] errors with \"-w\"" + n
+ newLine + n
+ "1.4.3" + newLine + "1.4.3" + n
+ "- Fixed \"-ps\",\"-printspawn\" as I had forgot I had broken it in 1.4.0 - due to config file change." + newLine + "- Fixed \"-ps\",\"-printspawn\" as I had forgot I had broken it in 1.4.0 - due to config file change." + n
+ newLine + n
+ "1.4.2" + newLine + "1.4.2" + n
+ "- No New Features" + newLine + "- No New Features" + n
+ "- Changed non-verbose mode to display server progress on the same line, saving a lot of space." + newLine + "- Changed non-verbose mode to display server progress on the same line, saving a lot of space." + n
+ " - This couldn't wait for 1.5.0 ... I (Morlok8k) liked it too much." + newLine + " - This couldn't wait for 1.5.0 ... I (Morlok8k) liked it too much." + n
+ newLine + n
+ "1.4.0" + newLine + "1.4.0" + n
+ "- Future Proofing" + newLine + "- Future Proofing" + n
+ "- Configurble Server Message reading. (If server updates and breaks MLG, you can add the new text!)" + newLine + "- Configurble Server Message reading. (If server updates and breaks MLG, you can add the new text!)" + n
+ "- Updated config file, and auto updating from old format." + newLine + "- Updated config file, and auto updating from old format." + n
+ "- Added % of spawn area to non-verbose output." + newLine + "- Added % of spawn area to non-verbose output." + n
+ "- Removed datetime stamps from server output in verbose mode" + newLine + "- Removed datetime stamps from server output in verbose mode" + n
+ "- Other Misc fixes." + newLine + "- Other Misc fixes." + n
+ newLine + n
+ "1.3.0" + newLine + "1.3.0" + n
+ "- Fixed Problems with Minecraft Beta 1.3 -- Morlok8k" + newLine + "- Fixed Problems with Minecraft Beta 1.3 -- Morlok8k" + n
+ newLine + n
+ "-----------------------------------------------" + newLine + "-----------------------------------------------" + n
+ newLine + n
+ "Corrodias:" + newLine + "Corrodias:" + n
+ "1.2.0" + newLine + "1.2.0" + n
+ "- land generation now centers on the spawn point instead of [0, 0]" + newLine + "- land generation now centers on the spawn point instead of [0, 0]" + n
+ "- the server is launched once before the spawn point is changed, to verify that it can run and to create a world if one doesn't exist" + newLine + "- the server is launched once before the spawn point is changed, to verify that it can run and to create a world if one doesn't exist" + n
+ "- added -printspawn [-ps] switch to print the current spawn coordinates to the console" + newLine + "- added -printspawn [-ps] switch to print the current spawn coordinates to the console" + n
+ "- added -x and -y switches to override the X and Y offsets" + newLine + "- added -x and -y switches to override the X and Y offsets" + n
+ "- added -v switch, does the same as -verbose" + newLine + "- added -v switch, does the same as -verbose" + n
+ "- improved status message spacing to make things easier to read" + newLine + "- improved status message spacing to make things easier to read" + n
+ "- improved time estimation algorithm: it now averages the last 3 launches" + newLine + "- improved time estimation algorithm: it now averages the last 3 launches" + n
+ newLine + n
+ "1.1.0" + newLine + "1.1.0" + n
+ "- added MinecraftLandGenerator.conf file to hold the java command line and the server path" + newLine + "- added MinecraftLandGenerator.conf file to hold the java command line and the server path" + n
+ "- added -conf solo switch to generate a .conf file" + newLine + "- added -conf solo switch to generate a .conf file" + n
+ "- added -verbose switch to output server output to the console (default is to ignore it)" + newLine + "- added -verbose switch to output server output to the console (default is to ignore it)" + n
+ "- added -i switch to allow customizing the block increment size (default is 300)" + newLine + "- added -i switch to allow customizing the block increment size (default is 300)" + n
+ "- added instructions output in this version, i think" + newLine + "- added instructions output in this version, i think" + n
+ "- improved status message output to include current iteration and total iterations" + newLine + "- improved status message output to include current iteration and total iterations" + n
+ newLine + n
+ "1.0.0" + newLine + "1.0.0" + n
+ "- initial release" + newLine + "- initial release" + n
+ newLine + n
+ "-----------------------------------------------" + newLine + "-----------------------------------------------" + n
+ newLine + n
+ "Notes:" + newLine + "Notes:" + n
+ "Due to changes in server beta 1.6, it now generates the nether as well as the world at the same time." + newLine + "Due to changes in server beta 1.6, it now generates the nether as well as the world at the same time." + n
+ "However, Since beta 1.9 and Minecraft 1.0, the nether or the end is no longer generated." + "However, Since beta 1.9 and Minecraft 1.0, the nether or the end is no longer generated."
+ "I recommend using MCEDIT to relight the map after you generate it. This will take a long time, but should fix all those incorrectly dark spots in your level." + newLine; + "I recommend using MCEDIT to relight the map after you generate it. This will take a long time, but should fix all those incorrectly dark spots in your level." + n;
//@formatter:on //@formatter:on
FileWrite.writeTxtFile(readmeFile, ReadMeText + showHelpSTR + VersionInfo); FileWrite.writeTxtFile(readmeFile, ReadMeText + showHelpSTR + VersionInfo);
@ -231,81 +227,77 @@ public class Readme_and_HelpInfo {
*/ */
public static String showHelp(final boolean SysOut) { public static String showHelp(final boolean SysOut) {
String Str = null; String Str = null;
String NewLine = newLine; String n = var.newLine;
if (SysOut) { if (SysOut) {
NewLine = NewLine + var.MLG; n = n + var.MLG;
} }
MLGFileNameShort = var.MLGFileNameShort;
MinecraftLandGeneratorConf = var.MinecraftLandGeneratorConf;
defaultReadmeFile = var.defaultReadmeFile;
//@formatter:off //@formatter:off
Str = "Usage: java -jar " + MLGFileNameShort + " x z [serverpath] [switches]" + NewLine Str = "Usage: java -jar " + var.MLGFileNameShort + " x z [serverpath] [switches]" + n
+ NewLine + n
+ "Arguments:" + NewLine + "Arguments:" + n
+ " x : X range to generate" + NewLine + " x : X range to generate" + n
+ " z : Z range to generate" + NewLine + " z : Z range to generate" + n
+ " serverpath : the path to the directory in which the server runs (takes precedence over the config file setting)" + NewLine + " serverpath : the path to the directory in which the server runs (takes precedence over the config file setting)" + n
+ NewLine + n
+ "Switches:" + NewLine + "Switches:" + n
+ " -verbose : causes the application to output the server's messages to the console" + NewLine + " -verbose : causes the application to output the server's messages to the console" + n
+ " -v : same as -verbose" + NewLine + " -v : same as -verbose" + n
+ " -w : Ignore [WARNING] and [SEVERE] messages." + NewLine + " -w : Ignore [WARNING] and [SEVERE] messages." + n
+ " -alt : alternate server launch sequence" + NewLine + " -alt : alternate server launch sequence" + n
+ " -a : same as -alt" + NewLine + " -a : same as -alt" + n
+ " -nowait : don't pause for anything" + NewLine + " -nowait : don't pause for anything" + n
+ " -n : same as -nowait" + NewLine + " -n : same as -nowait" + n
+ " -i# : override the iteration spawn offset increment (default 380) (example: -i100)" + NewLine + " -i# : override the iteration spawn offset increment (default 380) (example: -i100)" + n
+ " -x# : set the X offset to generate land around (example: -x0 or -x1000 or -x-500)" + NewLine + " -x# : set the X offset to generate land around (example: -x0 or -x1000 or -x-500)" + n
+ " -z# : set the Z offset to generate land around (example: -z0 or -z1000 or -z-500)" + NewLine + " -z# : set the Z offset to generate land around (example: -z0 or -z1000 or -z-500)" + n
+ NewLine + n
+ "Other options:" + NewLine + "Other options:" + n
+ " java -jar " + MLGFileNameShort + " -update" + NewLine + " java -jar " + var.MLGFileNameShort + " -update" + n
+ " Checks for and downloads new versions of MLG online." + NewLine + " Checks for and downloads new versions of MLG online." + n
+ NewLine + n
+ " java -jar " + MLGFileNameShort + " -printspawn" + NewLine + " java -jar " + var.MLGFileNameShort + " -printspawn" + n
+ " java -jar " + MLGFileNameShort + " -ps" + NewLine + " java -jar " + var.MLGFileNameShort + " -ps" + n
+ " Outputs the current world's spawn point coordinates." + NewLine + " Outputs the current world's spawn point coordinates." + n
+ NewLine + n
+ " java -jar " + MLGFileNameShort + " -conf" + NewLine + " java -jar " + var.MLGFileNameShort + " -conf" + n
+ " java -jar " + MLGFileNameShort + " -conf download" + NewLine + " java -jar " + var.MLGFileNameShort + " -conf download" + n
+ " Generates or downloads a "+ MinecraftLandGeneratorConf + " file." + NewLine + " Generates or downloads a "+ var.MinecraftLandGeneratorConf + " file." + n
+ NewLine + n
+ " java -jar " + MLGFileNameShort + " -readme readme.txt" + NewLine + " java -jar " + var.MLGFileNameShort + " -readme readme.txt" + n
+ " java -jar " + MLGFileNameShort + " -readme" + NewLine + " java -jar " + var.MLGFileNameShort + " -readme" + n
+ " Generates a readme file using supplied name or the default " + defaultReadmeFile + NewLine + " Generates a readme file using supplied name or the default " + var.defaultReadmeFile + n
+ NewLine + n
+ " java -jar " + MLGFileNameShort + " -downloadfile http://example.com/file.txt" + NewLine + " java -jar " + var.MLGFileNameShort + " -downloadfile http://example.com/file.txt" + n
+ " Downloads whatever file from the internet you give it." + NewLine + " Downloads whatever file from the internet you give it." + n
+ " java -jar " + MLGFileNameShort + " -downloadlist list.txt" + NewLine + " java -jar " + var.MLGFileNameShort + " -downloadlist list.txt" + n
+ " list.txt (or any other file) contains a URL on each line which will be downloaded." + NewLine + " list.txt (or any other file) contains a URL on each line which will be downloaded." + n
+ NewLine + n
+ " java -jar " + MLGFileNameShort + " -version" + NewLine + " java -jar " + var.MLGFileNameShort + " -version" + n
+ " java -jar " + MLGFileNameShort + " -help" + NewLine + " java -jar " + var.MLGFileNameShort + " -help" + n
+ " java -jar " + MLGFileNameShort + " /?" + NewLine + " java -jar " + var.MLGFileNameShort + " /?" + n
+ " Prints this message." + NewLine + " Prints this message." + n
+ NewLine + n
+ "When launched with the -conf switch, this application creates a " + MinecraftLandGeneratorConf + " file that contains configuration options." + NewLine + "When launched with the -conf switch, this application creates a " + var.MinecraftLandGeneratorConf + " file that contains configuration options." + n
+ "If this file does not exist or does not contain all required properties, the application will not run." + NewLine + "If this file does not exist or does not contain all required properties, the application will not run." + n
+ NewLine + n
+ MinecraftLandGeneratorConf + " properties:" + NewLine + var.MinecraftLandGeneratorConf + " properties:" + n
+ " Java : The command line to use to launch the server" + NewLine + " Java : The command line to use to launch the server" + n
+ " ServerPath : The path to the directory in which the server runs (can be overridden by the serverpath argument)" + NewLine + " ServerPath : The path to the directory in which the server runs (can be overridden by the serverpath argument)" + n
+ " Done_Text : The output from the server that tells us that we are done" + NewLine + " Done_Text : The output from the server that tells us that we are done" + n
+ " Preparing_Text : The output from the server that tells us the percentage" + NewLine + " Preparing_Text : The output from the server that tells us the percentage" + n
+ "Preparing_Level : The output from the server that tells us the level it is working on" + NewLine + "Preparing_Level : The output from the server that tells us the level it is working on" + n
+ " Level-0 : Name of Level 0: The Overworld" + NewLine + " Level-0 : Name of Level 0: The Overworld" + n
+ " Level-1 : Name of Level 1: The Nether" + NewLine + " Level-1 : Name of Level 1: The Nether" + n
+ " Level-2 : Name of Level 2: The End" + NewLine + " Level-2 : Name of Level 2: The End" + n
+ " Level-3 : Name of Level 3: (Future Level)" + NewLine + " Level-3 : Name of Level 3: (Future Level)" + n
+ " Level-4 : Name of Level 4: (Future Level)" + NewLine + " Level-4 : Name of Level 4: (Future Level)" + n
+ " Level-5 : Name of Level 5: (Future Level)" + NewLine + " Level-5 : Name of Level 5: (Future Level)" + n
+ " Level-6 : Name of Level 6: (Future Level)" + NewLine + " Level-6 : Name of Level 6: (Future Level)" + n
+ " Level-7 : Name of Level 7: (Future Level)" + NewLine + " Level-7 : Name of Level 7: (Future Level)" + n
+ " Level-8 : Name of Level 8: (Future Level)" + NewLine + " Level-8 : Name of Level 8: (Future Level)" + n
+ " Level-9 : Name of Level 9: (Future Level)" + NewLine + " Level-9 : Name of Level 9: (Future Level)" + n
+ " WaitSave : Optional: Wait before saving." + NewLine; + " WaitSave : Optional: Wait before saving." + n;
//@formatter:on //@formatter:on
String returnString = null; String returnString = null;

View File

@ -20,8 +20,12 @@ public class SelfAware {
Return = Return.trim(); Return = Return.trim();
Return = Return =
"Launch info: JVM: " + Return + " JAR: " + System.getProperty("sun.java.command") "Launch info: Java: " + System.getProperty("java.vm.name") + " "
+ " ARGS: "; + 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++) { for (int i = 0; i < var.originalArgs.length; i++) {
Return = Return + (var.originalArgs[i]) + " "; Return = Return + (var.originalArgs[i]) + " ";

View File

@ -16,7 +16,8 @@ public class Server {
* @throws IOException * @throws IOException
* @author Corrodias * @author Corrodias
*/ */
protected static boolean runMinecraft(final boolean alternate) throws IOException { protected static boolean runMinecraft() throws IOException {
if (var.verbose) { if (var.verbose) {
Main.out("Starting server."); Main.out("Starting server.");
} }
@ -28,7 +29,7 @@ public class Server {
// 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.
if (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.
Main.out("Alternate Launch"); Main.out("Alternate Launch");
final Process process = var.minecraft.start(); final Process process = var.minecraft.start();
@ -131,35 +132,34 @@ 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"
Main.outP(var.MLG + var.worldName + ": " + var.level_0 + ":" Main.outP(var.MLG + var.worldName + ": " + var.level_0 + ":" + var.newLine);
+ var.newLine);
} else if (line.contains("level 1")) { // "Preparing start region for level 1" } else if (line.contains("level 1")) { // "Preparing start region for level 1"
Main.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_1 Main.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.contains("level 2")) { // "Preparing start region for level 2"
Main.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_2 Main.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.contains("level 3")) { // "Preparing start region for level 3"
Main.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_3 Main.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.contains("level 4")) { // "Preparing start region for level 4"
Main.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_4 Main.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.contains("level 5")) { // "Preparing start region for level 5"
Main.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_5 Main.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.contains("level 6")) { // "Preparing start region for level 6"
Main.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_6 Main.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.contains("level 7")) { // "Preparing start region for level 7"
Main.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_7 Main.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.contains("level 8")) { // "Preparing start region for level 8"
Main.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_8 Main.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.contains("level 9")) { // "Preparing start region for level 9"
Main.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_9 Main.outP(var.newLine + var.MLG + var.worldName + ": " + var.level_9 + ":"
+ ":" + var.newLine); + var.newLine);
} else { } else {
Main.outP(var.newLine + var.MLG + shortLine); Main.outP(var.newLine + var.MLG + shortLine);
} }

View File

@ -10,26 +10,51 @@ import java.util.Scanner;
public class var { public class var {
// //
// // Program Info:
// Public Vars:
public static boolean testing = false; // display more output when debugging public static boolean testing = false; // display more output when debugging
public static boolean verbose = false;
public static final String PROG_NAME = "Minecraft Land Generator"; // Program Name public static final String PROG_NAME = "Minecraft Land Generator"; // Program Name
public static final String VERSION = "1.7.1 test 10"; // Version Number! public static final String VERSION = "1.7.1 test 10"; // Version Number!
public static final String AUTHORS = "Corrodias, Morlok8k, pr0f1x"; // Authors public static final String AUTHORS = "Corrodias, Morlok8k, pr0f1x"; // Authors
//
// Operating System Info:
public static final String fileSeparator = System.getProperty("file.separator"); public static final String fileSeparator = System.getProperty("file.separator");
public static final String newLine = System.getProperty("line.separator"); public static final String newLine = System.getProperty("line.separator");
public static String[] originalArgs = {};
//
// Commonly Used Strings:
public static String MLG = "[MLG] "; public static String MLG = "[MLG] ";
public static String MLGe = "[MLG-ERROR] "; public static String MLGe = "[MLG-ERROR] ";
//
// Date & Build-ID stuff:
public static DateFormat dateFormat_MDY = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH); public static DateFormat dateFormat_MDY = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
public static Date MLG_Last_Modified_Date = null; public static Date MLG_Last_Modified_Date = null;
public static DateFormat dateFormat = new SimpleDateFormat( // Lets get a nice Date format for display
"EEEE, MMMM d, yyyy 'at' h:mm a zzzz", Locale.ENGLISH);
public static Date date = null; // date stuff
public static Long MLG_Last_Modified_Long = 0L;
public static String buildIDFile = "MLG-BuildID";
//
// Filenames:
public static String MLGFileNameShort = null; public static String MLGFileNameShort = null;
public static Scanner sc = new Scanner(System.in);
public static final String MinecraftLandGeneratorConf = "MinecraftLandGenerator.conf"; public static final String MinecraftLandGeneratorConf = "MinecraftLandGenerator.conf";
public static final String defaultReadmeFile = "_MLG_Readme.txt"; public static final String defaultReadmeFile = "_MLG_Readme.txt";
public static final String MLG_JarFile = "MinecraftLandGenerator.jar";
public static String MLGFileName = null;
//
// Text Input
public static Scanner sc = new Scanner(System.in);
//
// MinecraftLandGenerator.conf Stuff:
public static String doneText = null; public static String doneText = null;
public static String preparingText = null; public static String preparingText = null;
public static String preparingLevel = null; public static String preparingLevel = null;
public static String level_0 = null; // the world public static String level_0 = null; // the world
public static String level_1 = null; // the nether public static String level_1 = null; // the nether
public static String level_2 = null; // the end public static String level_2 = null; // the end
@ -40,41 +65,59 @@ public class var {
public static String level_7 = null; public static String level_7 = null;
public static String level_8 = null; public static String level_8 = null;
public static String level_9 = null; public static String level_9 = null;
public static ProcessBuilder minecraft = null;
public static String javaLine = null;
public static final String defaultJavaLine = public static final String defaultJavaLine =
"java -Djava.awt.headless=true -Djline.terminal=jline.UnsupportedTerminal -Duser.language=en" "java -Djava.awt.headless=true -Djline.terminal=jline.UnsupportedTerminal -Duser.language=en"
+ " -Xms1024m -Xmx1024m -Xincgc -jar minecraft_server.jar nogui"; + " -Xms1024m -Xmx1024m -Xincgc -jar minecraft_server.jar nogui";
public static String serverPath = null; public static String serverPath = null;
public static String worldPath = null; public static String worldPath = null;
//
//Server Launching:
public static ProcessBuilder minecraft = null;
public static String javaLine = null;
//
//Server Launching:
public static String worldName = null; public static String worldName = null;
public static boolean verbose = false;
public static boolean dontWait = false;
public static boolean waitSave = false; public static boolean waitSave = false;
public static boolean ignoreWarnings = false; public static boolean ignoreWarnings = false;
public static Long randomSeed = (long) 0; public static Long randomSeed = (long) 0;
public static DateFormat dateFormat = new SimpleDateFormat( // Lets get a nice Date format for display
"EEEE, MMMM d, yyyy 'at' h:mm a zzzz", Locale.ENGLISH); //
public static Date date = null; // date stuff // Update URLs:
public static Long MLG_Last_Modified_Long = 0L;
public static final Class<?> cls = Main.class;
public static String MLGFileName = null;
public static final String rsrcError = "rsrcERROR";
public static String buildIDFile = "MLG-BuildID";
public static boolean isCompiledAsJar = false;
public static String MLG_Current_Hash = null;
public static int inf_loop_protect_BuildID = 0;
public static boolean flag_downloadedBuildID = false;
public static String MC_Server_Version = "";
public static ArrayList<String> timeStamps = new ArrayList<String>();
public static final String MLG_JarFile = "MinecraftLandGenerator.jar";
public static final String github_URL = public static final String github_URL =
"https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/bin/"; // just removing some redundancy "https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/bin/"; // just removing some redundancy
public static final String github_MLG_Conf_URL = github_URL + MinecraftLandGeneratorConf; public static final String github_MLG_Conf_URL = github_URL + MinecraftLandGeneratorConf;
public static final String github_MLG_BuildID_URL = github_URL + buildIDFile; public static final String github_MLG_BuildID_URL = github_URL + buildIDFile;
public static final String github_MLG_jar_URL = github_URL + MLG_JarFile; public static final String github_MLG_jar_URL = github_URL + MLG_JarFile;
//
// Update Stuff:
public static final Class<?> cls = Main.class;
public static final String rsrcError = "rsrcERROR";
public static boolean isCompiledAsJar = false;
public static String MLG_Current_Hash = null;
public static int inf_loop_protect_BuildID = 0;
public static boolean flag_downloadedBuildID = false;
public static ArrayList<String> timeStamps = new ArrayList<String>();
//
// Resume Data & Log Files
public static int resumeX = 0; //resume data, if needed. public static int resumeX = 0; //resume data, if needed.
public static int resumeZ = 0; public static int resumeZ = 0;
public static String[] originalArgs = {};
public static String MC_Server_Version = "";
//
// Misc:
public static boolean webLaunch = true; // Launch website after generation. public static boolean webLaunch = true; // Launch website after generation.
public static boolean dontWait = false;
public static boolean alternate = false;
public static int MinecraftServerChunkPlayerCache = 625; //You see this number when you first launch the server in GUI mode, after the world is loaded, but before anyone has connected.
public static int increment = (int) (Math.sqrt(MinecraftServerChunkPlayerCache) * 16) - 20; //private int increment = 380;
public static boolean assertsEnabled = false; //debugging use... use java -ea -jar MinecraftlandGenerator.jar...
public static long startTime = 0L;
public static Boolean recheckFlag = false;
} }