1.6.0 (test12)

This commit is contained in:
Morlok8k 2011-11-04 03:22:43 -07:00
parent f1907d0eea
commit 98d0e3f219
4 changed files with 71 additions and 132 deletions

7
README
View File

@ -1,4 +1,4 @@
Minecraft Land Generator version 1.6.0 Testing 11 Minecraft Land Generator version 1.6.0 Testing 12
Updated November 4, 2011 Updated November 4, 2011
@ -25,9 +25,10 @@ Morlok8k:
1.6.0 1.6.0
- TODO: add features - TODO: add features
- Added the ability to download files from the internet (specifically for the BuildID file) - Added the ability to download files from the internet (specifically for the BuildID file, and conf file)
- Added the ability to check what version the .jar is. (Using MD5 hashes, timestamps, and the BuildID file) - Added the ability to check what version the .jar is. (Using MD5 hashes, timestamps, and the BuildID file)
- Minor Refactoring - Some Refactoring
- Code Formatting
1.5.1 1.5.1
- pr0f1x: Added the "save-all" command to be sent to the server before shutting it down. - pr0f1x: Added the "save-all" command to be sent to the server before shutting it down.

View File

@ -1,2 +1,3 @@
919315DC465C9A821A857FCBE789C571=1320395554000#MLG v1.6.0 Testing 8 919315DC465C9A821A857FCBE789C571=1320395554000#MLG v1.6.0 Testing 8
293A184EB26A62AE6D64CEB01BAD9537=1320399076000#MLG v1.6.0 Testing 11 293A184EB26A62AE6D64CEB01BAD9537=1320399076000#MLG v1.6.0 Testing 11
4F00853101546B5C030F5D89036EC574=1320402115000#MLG v1.6.0 Testing 12

Binary file not shown.

View File

@ -45,7 +45,7 @@ import org.jnbt.Tag;
public class Main { public class Main {
// Version Number! // Version Number!
private static final String VERSION = "1.6.0 Testing 11"; private static final String VERSION = "1.6.0 Testing 12";
private static final String AUTHORS = "Corrodias, Morlok8k, pr0f1x"; private static final String AUTHORS = "Corrodias, Morlok8k, pr0f1x";
private static final String fileSeparator = System.getProperty("file.separator"); private static final String fileSeparator = System.getProperty("file.separator");
@ -116,8 +116,7 @@ public class Main {
* the command line arguments * the command line arguments
*/ */
public static void main(String[] args) { public static void main(String[] args) {
(new Main()).run(args); // Why? idk, but merging this with run() creates (new Main()).run(args); // Why? idk, but merging this with run() creates errors, and i'm lazy!
// errors, and i'm lazy!
} }
/** /**
@ -128,8 +127,7 @@ public class Main {
*/ */
private void run(String[] args) { private void run(String[] args) {
// Lets get a nice Date format for display, and a compact one for // Lets get a nice Date format for display, and a compact one for telling apart builds.
// telling apart builds.
dateFormat = new SimpleDateFormat("EEEE, MMMM d, yyyy 'at' h:mm a zzzz", Locale.ENGLISH); dateFormat = new SimpleDateFormat("EEEE, MMMM d, yyyy 'at' h:mm a zzzz", Locale.ENGLISH);
dateFormatBuildID = new SimpleDateFormat("'BuildID:' (yyMMdd.HHmmss)", Locale.ENGLISH); dateFormatBuildID = new SimpleDateFormat("'BuildID:' (yyMMdd.HHmmss)", Locale.ENGLISH);
dateFormat_MDY = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH); dateFormat_MDY = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
@ -138,10 +136,7 @@ public class Main {
readBuildID(); readBuildID();
//readMe("test.txt"); // The following displays no matter what happens, so we needed this date stuff to happen first.
// The following displays no matter what happens, so we needed this date
// stuff to happen first.
// MLG_Last_Modified_Date = date; // MLG_Last_Modified_Date = date;
@ -336,9 +331,10 @@ public class Main {
if (serverPath == null || javaLine == null) { // MLG 1.2 Check for a valid .conf file. if (serverPath == null || javaLine == null) { // MLG 1.2 Check for a valid .conf file.
System.err.println(MLG + MinecraftLandGeneratorConf System.err.println(MLG + MinecraftLandGeneratorConf
+ " does not contain all required properties. Making New File!"); + " does not contain all required properties. Making New File!"); // Please recreate it by running this application with -conf.
// Please recreate it by running this application with -conf.
// return; // return;
// We no longer quit. We generate a new one with defaults. // We no longer quit. We generate a new one with defaults.
javaLine = defaultJavaLine; javaLine = defaultJavaLine;
@ -346,15 +342,15 @@ public class Main {
oldConf = true; oldConf = true;
} }
if (doneText == null) { // MLG 1.3 if (doneText == null) { // MLG 1.4.0
oldConf = true; oldConf = true;
} else if (preparingText == null) { // MLG 1.4? } else if (preparingText == null) { // MLG 1.4.0
oldConf = true; oldConf = true;
} else if (preparingLevel == null) { // MLG 1.4? } else if (preparingLevel == null) { // MLG 1.4.5 / 1.5.0
oldConf = true; oldConf = true;
} else if (level_1 == null) { // MLG 1.5.0? } else if (level_1 == null) { // MLG 1.4.5 / 1.5.0
oldConf = true; oldConf = true;
} else if (level_0 == null) { // MLG 1.5.1 } else if (level_0 == null) { // MLG 1.5.1 / 1.6.0
oldConf = true; oldConf = true;
} }
@ -608,22 +604,13 @@ public class Main {
+ ") " + ") "
+ Float.toString((Float.parseFloat(Integer + Float.toString((Float.parseFloat(Integer
.toString(currentIteration)) / Float.parseFloat(Integer .toString(currentIteration)) / Float.parseFloat(Integer
.toString(totalIterations))) * 100) + "% Done"); // Time .toString(totalIterations))) * 100) + "% Done"); // Time Remaining estimate
// Remaining
// estimate
timeTracking[0] = timeTracking[1]; timeTracking[0] = timeTracking[1];
timeTracking[1] = timeTracking[2]; timeTracking[1] = timeTracking[2];
timeTracking[2] = timeTracking[3]; timeTracking[2] = timeTracking[3];
timeTracking[3] = System.currentTimeMillis(); timeTracking[3] = System.currentTimeMillis();
if (currentIteration >= 4) { if (currentIteration >= 4) {
differenceTime = (timeTracking[3] - timeTracking[0]) / 3; // well, differenceTime = (timeTracking[3] - timeTracking[0]) / 3; // well, this is what it boils down to
// this
// is
// what
// it
// boils
// down
// to
differenceTime *= 1 + (totalIterations - currentIteration); differenceTime *= 1 + (totalIterations - currentIteration);
System.out System.out
.println(MLG .println(MLG
@ -633,14 +620,7 @@ public class Main {
(differenceTime % (1000 * 60 * 60)) / (1000 * 60), (differenceTime % (1000 * 60 * 60)) / (1000 * 60),
((differenceTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000)); ((differenceTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000));
} else if (currentIteration == 3) { } else if (currentIteration == 3) {
differenceTime = (timeTracking[3] - timeTracking[1]) / 2; // well, differenceTime = (timeTracking[3] - timeTracking[1]) / 2; // well, this is what it boils down to
// this
// is
// what
// it
// boils
// down
// to
differenceTime *= 1 + (totalIterations - currentIteration); differenceTime *= 1 + (totalIterations - currentIteration);
System.out System.out
.println(MLG .println(MLG
@ -650,14 +630,7 @@ public class Main {
(differenceTime % (1000 * 60 * 60)) / (1000 * 60), (differenceTime % (1000 * 60 * 60)) / (1000 * 60),
((differenceTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000)); ((differenceTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000));
} else if (currentIteration == 2) { } else if (currentIteration == 2) {
differenceTime = (timeTracking[3] - timeTracking[2]); // well, differenceTime = (timeTracking[3] - timeTracking[2]); // well, this is what it boils down to
// this
// is
// what
// it
// boils
// down
// to
differenceTime *= 1 + (totalIterations - currentIteration); differenceTime *= 1 + (totalIterations - currentIteration);
System.out System.out
.println(MLG .println(MLG
@ -744,56 +717,41 @@ public class Main {
CompoundTag originalTopLevelTag = (CompoundTag) input.readTag(); CompoundTag originalTopLevelTag = (CompoundTag) input.readTag();
input.close(); input.close();
// <editor-fold defaultstate="collapsed" desc="structure"> //@formatter:off
// Structure:
//
// TAG_Compound("Data"): World data. /* <editor-fold defaultstate="collapsed" desc="structure">
// * TAG_Long("Time"): Stores the current "time of day" in ticks. * Structure:
// There are 20 ticks per real-life second, and 24000 ticks per *
// Minecraft day, making the day length 20 minutes. 0 appears to be *TAG_Compound("Data"): World data.
// sunrise, 12000 sunset and 24000 sunrise again. * * TAG_Long("Time"): Stores the current "time of day" in ticks. There are 20 ticks per real-life second, and 24000 ticks per Minecraft day, making the day length 20 minutes. 0 appears to be sunrise, 12000 sunset and 24000 sunrise again.
// * TAG_Long("LastPlayed"): Stores the Unix time stamp (in * * TAG_Long("LastPlayed"): Stores the Unix time stamp (in milliseconds) when the player saved the game.
// milliseconds) when the player saved the game. * * TAG_Compound("Player"): Player entity information. See Entity Format and Mob Entity Format for details. Has additional elements:
// * TAG_Compound("Player"): Player entity information. See Entity * o TAG_List("Inventory"): Each TAG_Compound in this list defines an item the player is carrying, holding, or wearing as armor.
// Format and Mob Entity Format for details. Has additional * + TAG_Compound: Inventory item data
// elements: * # TAG_Short("id"): Item or Block ID.
// o TAG_List("Inventory"): Each TAG_Compound in this list defines * # TAG_Short("Damage"): The amount of wear each item has suffered. 0 means undamaged. When the Damage exceeds the item's durability, it breaks and disappears. Only tools and armor accumulate damage normally.
// an item the player is carrying, holding, or wearing as armor. * # TAG_Byte("Count"): Number of items stacked in this inventory slot. Any item can be stacked, including tools, armor, and vehicles. Range is 1-255. Values above 127 are not displayed in-game.
// + TAG_Compound: Inventory item data * # TAG_Byte("Slot"): Indicates which inventory slot this item is in.
// # TAG_Short("id"): Item or Block ID. * o TAG_Int("Score"): Current score, doesn't appear to be implemented yet. Always 0.
// # TAG_Short("Damage"): The amount of wear each item has suffered. * * TAG_Int("SpawnX"): X coordinate of the player's spawn position. Default is 0.
// 0 means undamaged. When the Damage exceeds the item's durability, * * TAG_Int("SpawnY"): Y coordinate of the player's spawn position. Default is 64.
// it breaks and disappears. Only tools and armor accumulate damage * * TAG_Int("SpawnZ"): Z coordinate of the player's spawn position. Default is 0.
// normally. * * TAG_Byte("SnowCovered"): 1 enables, 0 disables, see Winter Mode
// # TAG_Byte("Count"): Number of items stacked in this inventory * * TAG_Long("SizeOnDisk"): Estimated size of the entire world in bytes.
// slot. Any item can be stacked, including tools, armor, and * * TAG_Long("RandomSeed"): Random number providing the Random Seed for the terrain.
// vehicles. Range is 1-255. Values above 127 are not displayed * </editor-fold>
// in-game. */
// # TAG_Byte("Slot"): Indicates which inventory slot this item is
// in.
// o TAG_Int("Score"): Current score, doesn't appear to be
// implemented yet. Always 0. //@formatter:on
// * TAG_Int("SpawnX"): X coordinate of the player's spawn position.
// Default is 0.
// * TAG_Int("SpawnY"): Y coordinate of the player's spawn position.
// Default is 64.
// * TAG_Int("SpawnZ"): Z coordinate of the player's spawn position.
// Default is 0.
// * TAG_Byte("SnowCovered"): 1 enables, 0 disables, see Winter Mode
// //Old!
// * TAG_Long("SizeOnDisk"): Estimated size of the entire world in
// bytes.
// * TAG_Long("RandomSeed"): Random number providing the Random Seed
// for the terrain.
// </editor-fold>
Map<String, Tag> originalData = Map<String, Tag> originalData =
((CompoundTag) originalTopLevelTag.getValue().get("Data")).getValue(); ((CompoundTag) originalTopLevelTag.getValue().get("Data")).getValue();
// This is our map of data. It is an unmodifiable map, for some // This is our map of data. It is an unmodifiable map, for some reason, so we have to make a copy.
// reason, so we have to make a copy.
Map<String, Tag> newData = new LinkedHashMap<String, Tag>(originalData); Map<String, Tag> newData = new LinkedHashMap<String, Tag>(originalData);
// .get() a couple of values, just to make sure we're dealing with a // .get() a couple of values, just to make sure we're dealing with a valid level file, here. Good for debugging, too.
// valid level file, here. Good for debugging, too.
@SuppressWarnings("unused") @SuppressWarnings("unused")
IntTag spawnX = (IntTag) newData.get("SpawnX"); // we never use these... Its only here for potential debugging. IntTag spawnX = (IntTag) newData.get("SpawnX"); // we never use these... Its only here for potential debugging.
@ -918,19 +876,12 @@ public class Main {
String line = null; String line = null;
byte[] stop = { 's', 't', 'o', 'p', '\r', '\n' }; // Moved here, so byte[] stop = { 's', 't', 'o', 'p', '\r', '\n' }; // Moved here, so this code wont run every loop, thus Faster!
// this code
// wont run
// every loop,
// thus Faster!
// and no, i can't use a string here! // and no, i can't use a string here!
byte[] saveAll = { 's', 'a', 'v', 'e', '-', 'a', 'l', 'l', '\r', '\n' }; byte[] saveAll = { 's', 'a', 'v', 'e', '-', 'a', 'l', 'l', '\r', '\n' };
OutputStream outputStream = process.getOutputStream(); // moved here OutputStream outputStream = process.getOutputStream(); // moved here to remove some redundancy
// to remove
// some
// redundancy
while ((line = pOut.readLine()) != null) { while ((line = pOut.readLine()) != null) {
if (verbose) { if (verbose) {
@ -1012,24 +963,19 @@ public class Main {
} }
} }
if (ignoreWarnings == false) { if (ignoreWarnings == false) {
if (line.contains("[WARNING]")) { // If we have a warning, if (line.contains("[WARNING]")) { // If we have a warning, stop...
// stop...
System.out.println(""); System.out.println("");
System.out System.out
.println(MLG + "Warning found: Stopping Minecraft Land Generator"); .println(MLG + "Warning found: Stopping Minecraft Land Generator");
if (verbose == false) { // If verbose is true, we if (verbose == false) { // If verbose is true, we already displayed it.
// already displayed it.
System.out.println(line); System.out.println(line);
} }
System.out.println(""); System.out.println("");
System.out.println(MLG + "Forcing Save..."); System.out.println(MLG + "Forcing Save...");
outputStream.write(saveAll); outputStream.write(saveAll);
outputStream.flush(); outputStream.flush();
// OutputStream outputStream = // OutputStream outputStream = process.getOutputStream();
// process.getOutputStream(); outputStream.write(stop); // if the warning was a fail to bind to port, we may need to write stop twice!
outputStream.write(stop); // if the warning was a fail
// to bind to port, we may
// need to write stop twice!
outputStream.flush(); outputStream.flush();
outputStream.write(stop); outputStream.write(stop);
outputStream.flush(); outputStream.flush();
@ -1037,24 +983,20 @@ public class Main {
warning = true; warning = true;
// System.exit(1); // System.exit(1);
} }
if (line.contains("[SEVERE]")) { // If we have a severe if (line.contains("[SEVERE]")) { // If we have a severe error, stop...
// error, stop...
System.out.println(""); System.out.println("");
System.out.println(MLG + "Severe error found: Stopping server."); System.out.println(MLG + "Severe error found: Stopping server.");
if (verbose == false) { // If verbose is true, we if (verbose == false) { // If verbose is true, we already displayed it.
// already displayed it.
System.out.println(line); System.out.println(line);
} }
System.out.println(""); System.out.println("");
System.out.println(MLG + "Forcing Save..."); System.out.println(MLG + "Forcing Save...");
outputStream.write(saveAll); outputStream.write(saveAll);
outputStream.flush(); outputStream.flush();
// OutputStream outputStream = // OutputStream outputStream = process.getOutputStream();
// process.getOutputStream();
outputStream.write(stop); outputStream.write(stop);
outputStream.flush(); outputStream.flush();
outputStream.write(stop); // sometimes we need to do outputStream.write(stop); // sometimes we need to do stop twice...
// stop twice...
outputStream.flush(); outputStream.flush();
// outputStream.close(); // outputStream.close();
warning = true; warning = true;
@ -1064,10 +1006,7 @@ public class Main {
} }
} }
if (warning == true) { // in 1.4.4 we had a issue. tried to write 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.
// stop twice, but we had closed the stream
// already. this, and other lines should fix
// this.
outputStream.flush(); outputStream.flush();
outputStream.close(); outputStream.close();
System.exit(1); System.exit(1);
@ -1256,10 +1195,11 @@ public class Main {
+ "Morlok8k:" + newLine + "Morlok8k:" + newLine
+ newLine + newLine
+ "1.6.0" + newLine + "1.6.0" + newLine
+ "- TODO: add features" + newLine + "- TODO: add features" + newLine //TODO
+ "- Added the ability to download files from the internet (specifically for the BuildID file)" + newLine + "- Added the ability to download files from the internet (specifically for the BuildID file, and conf file)" + newLine
+ "- 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)" + newLine
+ "- Minor Refactoring" + newLine + "- Some Refactoring" + newLine
+ "- Code Formatting" + newLine
+ newLine + newLine
+ "1.5.1" + newLine + "1.5.1" + newLine
+ "- 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." + newLine
@ -1376,8 +1316,7 @@ public class Main {
boolean success = true; boolean success = true;
String fileName = URL.substring(URL.lastIndexOf("/") + 1, URL.length()); String fileName = URL.substring(URL.lastIndexOf("/") + 1, URL.length());
int size = 1024 * 4; // 1024 * n should be tested to get the optimum int size = 1024 * 4; // 1024 * n should be tested to get the optimum size (for download speed.)
// size (for download speed.)
if (fileName.equals("")) { if (fileName.equals("")) {
fileName = String.valueOf(System.currentTimeMillis()); fileName = String.valueOf(System.currentTimeMillis());
@ -1588,8 +1527,7 @@ public class Main {
if (end == -1) { // If we have no hash sign, then we read till the end of the line if (end == -1) { // If we have no hash sign, then we read till the end of the line
end = line.length(); end = line.length();
} }
if (end <= pos) { // If hash is before the '=', we may have an issue... it should be fine, cause we check for issues next, but lets make if (end <= pos) { // If hash is before the '=', we may have an issue... it should be fine, cause we check for issues next, but lets make sure.
// sure.
end = line.length(); end = line.length();
} }
@ -1645,8 +1583,7 @@ public class Main {
if (bang == -1) { // a real example: if (bang == -1) { // a real example:
bang = filename.length(); // jar:file:/home/morlok8k/test.jar!/me/Morlok8k/test/Main.class bang = filename.length(); // jar:file:/home/morlok8k/test.jar!/me/Morlok8k/test/Main.class
} }
int file = filename.indexOf("file:"); // removes junk from the beginning int file = filename.indexOf("file:"); // removes junk from the beginning of the path
// of the path
file = file + 5; file = file + 5;
if (file == -1) { if (file == -1) {
file = 0; file = 0;