diff --git a/README b/README index ffb5c18..349f032 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Minecraft Land Generator version 1.6.0 Testing 16 +Minecraft Land Generator version 1.6.0 Testing 21 Updated November 4, 2011 diff --git a/bin/MLG-BuildID b/bin/MLG-BuildID index 4269672..296012a 100644 --- a/bin/MLG-BuildID +++ b/bin/MLG-BuildID @@ -2,3 +2,4 @@ 293A184EB26A62AE6D64CEB01BAD9537=1320399076000#MLG v1.6.0 Testing 11 4F00853101546B5C030F5D89036EC574=1320402115000#MLG v1.6.0 Testing 12 E77F9F6977FA5BE75D81CA8E3584DCF8=1320404362000#MLG v1.6.0 Testing 16 +867265064E26F0F83EAC586C80ED5604=1320416550000# MLG v1.6.0 Testing 21 diff --git a/bin/MinecraftLandGenerator.conf b/bin/MinecraftLandGenerator.conf index 234887f..0925588 100644 --- a/bin/MinecraftLandGenerator.conf +++ b/bin/MinecraftLandGenerator.conf @@ -1,6 +1,6 @@ -#Minecraft Land Generator Configuration File: Version: 1.6.0 Testing 16 +#Minecraft Land Generator Configuration File: Version: 1.6.0 Testing 21 #Authors: Corrodias, Morlok8k, pr0f1x -#Auto-Generated: Friday, November 4, 2011 at 3:59 AM Pacific Daylight Time +#Auto-Generated: Friday, November 4, 2011 at 7:22 AM Pacific Daylight Time #Line to run server: Java=java -Djava.awt.headless=true -Djline.terminal=jline.UnsupportedTerminal -Duser.language=en -Xms1024m -Xmx1024m -Xincgc -jar minecraft_server.jar nogui diff --git a/bin/MinecraftLandGenerator.jar b/bin/MinecraftLandGenerator.jar index 3d08a1e..28581e8 100755 Binary files a/bin/MinecraftLandGenerator.jar and b/bin/MinecraftLandGenerator.jar differ diff --git a/src/corrodias/minecraft/landgenerator/Main.java b/src/corrodias/minecraft/landgenerator/Main.java index 3043c9e..d041cea 100644 --- a/src/corrodias/minecraft/landgenerator/Main.java +++ b/src/corrodias/minecraft/landgenerator/Main.java @@ -23,8 +23,10 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; @@ -41,11 +43,12 @@ import org.jnbt.Tag; /** * * @author Corrodias, Morlok8k, pr0f1x + * */ public class Main { // Version Number! - private static final String VERSION = "1.6.0 Testing 16"; + private static final String VERSION = "1.6.0 Testing 21"; private static final String AUTHORS = "Corrodias, Morlok8k, pr0f1x"; private static final String fileSeparator = System.getProperty("file.separator"); @@ -103,6 +106,9 @@ public class Main { "https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/bin/MinecraftLandGenerator.conf"; private static final String github_MLG_BuildID_URL = "https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/bin/MLG-BuildID"; + private static final String github_MLG_jar_URL = + "https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/bin/MinecraftLandGenerator.jar"; + private static final String MinecraftLandGeneratorConf = "MinecraftLandGenerator.conf"; ////// @@ -1435,14 +1441,18 @@ public class Main { } try { + String line; + BufferedReader in = new BufferedReader(new FileReader(buildIDFile)); BufferedWriter out = new BufferedWriter(new FileWriter(buildIDFile + ".temp")); - String line; + while ((line = in.readLine()) != null) { if (line.contains(MLG_Current_Hash)) { notNew = true; - // System.out.println("[DEBUG] NotNew"); + if (testing) { + System.out.println("[DEBUG] NotNew"); + } } out.write(line); @@ -1450,7 +1460,7 @@ public class Main { } if (notNew == false) { - out.write(MLG_Current_Hash + "=" + String.valueOf(time.getTime()) + "#MLG v" + out.write(MLG_Current_Hash + "=" + String.valueOf(time.getTime()) + "# MLG v" + VERSION + INFO); out.newLine(); } @@ -1517,6 +1527,9 @@ public class Main { } } + int tsCount = 0; + ArrayList timeStamps = new ArrayList(); + if (MLG_Last_Modified_Date == null) { boolean foundLine = false; try { @@ -1525,25 +1538,33 @@ public class Main { 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) { // 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(); + } + + timeStamps.add(line.substring(pos + 1, end)); + + if (testing) { + System.out.println(timeStamps.get(tsCount)); + } + + tsCount++; + if (line.contains(MLG_Current_Hash)) { // System.out.println("[DEBUG] Found!"); foundLine = true; - 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) { // 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(); - } - if (pos != -1) { if (line.substring(0, pos).equals(MLG_Current_Hash)) { MLG_Last_Modified_Date = new Date(new Long(line.substring(pos + 1, end))); - return; + //return; } } @@ -1552,6 +1573,50 @@ public class Main { } in.close(); + Iterator e = timeStamps.iterator(); + String s; + int diff; + //boolean renameFailed = false; + + while (e.hasNext()) { + s = e.next(); + diff = MLG_Last_Modified_Date.compareTo(new Date(new Long(s))); + //System.out.println(diff); + + if (diff < 0) { // if this is less than 0, there is a new version of MLG on the Internet! + System.out + .println("There is a NEW VERSION Of Minecraft Land Generator available online!"); + + try { + File fileRename = new File("MinecraftLandGenerator.jar"); + fileRename.renameTo(new File("MinecraftLandGenerator.jar" + ".old")); + } catch (Exception e1) { + System.out.println("Rename failed"); + e1.printStackTrace(); + + try { + copyFile(new File("MinecraftLandGenerator.jar"), new File( + "MinecraftLandGenerator.jar" + ".old")); + File fileDelete = new File("MinecraftLandGenerator.jar"); + fileDelete.delete(); + } catch (Exception e2) { + System.out.println("Rename 2 failed"); + e2.printStackTrace(); + //renameFailed = true; + return; + } + + } + + boolean fileSuccess = downloadFile(github_MLG_jar_URL); + if (fileSuccess) { + System.out.println(MLG + "MinecraftLandGenerator.jar" + " downloaded."); + return; + } + + } + } + if (foundLine == false) { // System.out.println("[DEBUG] FoundLine False"); buildID();