Some refactoring, cleaning up, etc.

This commit is contained in:
Morlok8k 2012-09-25 01:10:49 -07:00
parent 173a274b47
commit ca0c96b204
22 changed files with 667 additions and 368 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
*.class
*.backup
*.*~

View File

@ -11,6 +11,12 @@ import java.util.ArrayList;
*/
public class Arraylist {
/**
*
* @param list
* @param remove
* @return
*/
public static ArrayList<Coordinates> arrayListRemove(final ArrayList<Coordinates> list,
final ArrayList<Coordinates> remove) {
@ -23,5 +29,4 @@ public class Arraylist {
return list;
}
}

View File

@ -21,6 +21,7 @@ public class Coordinates {
*
* @param StringOfCoords
* A short- or long-form coordinate string as described at the two toString() methods
* @return
* @author Morlok8k
*/
public static Coordinates parseString(String StringOfCoords) {
@ -88,6 +89,7 @@ public class Coordinates {
*
* @param stringOfCoords
* A short- or long-form coordinate string as described at the two toString() methods
* @return
* @author jaseg
*/
public static Coordinates parseStringRegEx(String stringOfCoords) {
@ -131,10 +133,17 @@ public class Coordinates {
return new Coordinates(X, Y, Z);
}
/**
*
*/
public int X = 0;
/**
*
*/
public int Y = 0;
/**
*
*/
public int Z = 0;
/**
@ -156,6 +165,9 @@ public class Coordinates {
Z = z;
}
/**
*
*/
public void clear() {
X = 0;
Y = 0;
@ -242,7 +254,6 @@ public class Coordinates {
///////////////////////////////////////////////////////////////////////////////////////
// Java Language Specific Crap Below... Stuff *gotta* be there so Java won't cry... //
///////////////////////////////////////////////////////////////////////////////////////
/**
* @param y
* the y to set
@ -274,6 +285,11 @@ public class Coordinates {
}
/**
*
* @param Short
* @return
*/
public String toString(final boolean Short) {
if (Short) { // We are overloading toString with an additional option:
return ("(" + X + "," + Z + ")"); // Basically just an option to return just X and Z (formatted differently as well: "(X,Z)")

View File

@ -10,6 +10,10 @@ import java.net.URL;
import org.w3c.bert_bos.UTF8URL.Unescape;
/**
*
* @author morlok8k
*/
public class DownloadFile {
/**
@ -103,5 +107,4 @@ public class DownloadFile {
}
return success;
}
}

View File

@ -7,8 +7,17 @@ import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
/**
*
* @author morlok8k
*/
public class FileRead {
/**
*
* @param file
* @return
*/
public static ArrayList<Coordinates> readArrayListCoordLog(final String file) {
final ArrayList<Coordinates> Return = new ArrayList<Coordinates>();
@ -183,5 +192,4 @@ public class FileRead {
return;
}
}
}

View File

@ -5,6 +5,10 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
/**
*
* @author morlok8k
*/
public class FileWrite {
/**
@ -116,5 +120,4 @@ public class FileWrite {
}
}
}

View File

@ -8,10 +8,14 @@ import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
/**
*
* @author morlok8k
*/
public class MLG_GUI extends JFrame {
private static final long serialVersionUID = -8791419906463664152L; //auto generated
private JPanel contentPane;
private final JPanel contentPane;
/**
* Create the frame.
@ -24,9 +28,8 @@ public class MLG_GUI extends JFrame {
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JLabel lblHelloWorld = new JLabel("Hello World");
final JLabel lblHelloWorld = new JLabel("Hello World");
lblHelloWorld.setHorizontalAlignment(SwingConstants.CENTER);
contentPane.add(lblHelloWorld, BorderLayout.CENTER);
}
}

View File

@ -1,5 +1,9 @@
package morlok8k.MinecraftLandGenerator;
/**
*
* @author morlok8k
*/
public class Input_CLI {
/**
@ -30,5 +34,4 @@ public class Input_CLI {
return Return;
}
}

View File

@ -9,6 +9,10 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
/**
*
* @author morlok8k
*/
public class MD5 {
/**
@ -17,6 +21,10 @@ public class MD5 {
* Thanks to R.J. Lorimer at <br>
* <a href="http://www.javalobby.org/java/forums/t84420.html">http://www. javalobby.org/java/forums/t84420.html</a>
*
* @param fileName
* @return
* @throws NoSuchAlgorithmException
* @throws FileNotFoundException
* @author Morlok8k
*/
public static String fileMD5(final String fileName) throws NoSuchAlgorithmException,

View File

@ -23,9 +23,21 @@ import morlok8k.MinecraftLandGenerator.GUI.MLG_GUI;
*/
public class Main {
/**
*
*/
public static int xRange = 0;
/**
*
*/
public static int zRange = 0;
/**
*
*/
public static Integer zOffset = null;
/**
*
*/
public static Integer xOffset = null;
//////////////////////////////////////////////////////////
@ -34,12 +46,10 @@ public class Main {
// "final" means "constant" //
// public/private shows/hides between classes //
//////////////////////////////////////////////////////////
/**
* @param args
* the command line arguments
*/
public static void main(String[] args) {
var.startTime = System.currentTimeMillis();
@ -97,9 +107,9 @@ public class Main {
@Override
public void run() {
try {
MLG_GUI frame = new MLG_GUI();
final MLG_GUI frame = new MLG_GUI();
frame.setVisible(true);
} catch (Exception e) {
} catch (final Exception e) {
e.printStackTrace();
}
}

View File

@ -7,6 +7,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
*
* @author morlok8k
*/
public class Misc {
/**
@ -57,5 +61,4 @@ public class Misc {
return false;
}
}
}

View File

@ -1,5 +1,9 @@
package morlok8k.MinecraftLandGenerator;
/**
*
* @author morlok8k
*/
public class Out {
/**
@ -56,5 +60,4 @@ public class Out {
static void outS(final String str) {
System.out.println("[Server] " + str);
}
}

View File

@ -1,5 +1,9 @@
package morlok8k.MinecraftLandGenerator;
/**
*
* @author morlok8k
*/
public class Readme_and_HelpInfo {
/**
@ -223,6 +227,7 @@ public class Readme_and_HelpInfo {
* <br>
* Set TRUE to display info to System.out. (Returns null) <br>
* Set FALSE to return info as String.
* @return
* @author Morlok8k
*/
public static String showHelp(final boolean SysOut) {
@ -262,7 +267,7 @@ public class Readme_and_HelpInfo {
+ n
+ " java -jar " + var.MLGFileNameShort + " -conf" + n
+ " java -jar " + var.MLGFileNameShort + " -conf download" + n
+ " Generates or downloads a "+ var.MinecraftLandGeneratorConf + " file." + n
+ " Generates or downloads a " + var.MinecraftLandGeneratorConf + " file." + n
+ n
+ " java -jar " + var.MLGFileNameShort + " -readme readme.txt" + n
+ " java -jar " + var.MLGFileNameShort + " -readme" + n
@ -311,5 +316,4 @@ public class Readme_and_HelpInfo {
return returnString;
}
}

View File

@ -4,8 +4,16 @@ 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 = "";
@ -34,5 +42,4 @@ public class SelfAware {
Return = Return.trim();
return Return;
}
}

View File

@ -5,14 +5,17 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
/**
*
* @author morlok8k
*/
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.
*
* @param minecraft
*
* @return
* @throws IOException
* @author Corrodias
*/
@ -298,5 +301,4 @@ public class Server {
// while loop has finished now.
return serverSuccess;
}
}

View File

@ -15,6 +15,10 @@ import org.jnbt.NBTInputStream;
import org.jnbt.NBTOutputStream;
import org.jnbt.Tag;
/**
*
* @author morlok8k
*/
public class SpawnPoint {
//TODO: update this
@ -137,5 +141,4 @@ public class SpawnPoint {
throw new IOException("Invalid level format.");
}
}
}

View File

@ -1,7 +1,17 @@
package morlok8k.MinecraftLandGenerator;
/**
*
* @author morlok8k
*/
public class StringArrayParse {
/**
*
* @param array
* @param ParseOut
* @return
*/
public static String[] Parse(final String[] array, final String ParseOut) {
//There is probably a better way to do this.
@ -44,5 +54,4 @@ public class StringArrayParse {
return array; //no changes have been done, return the original array
}
}

View File

@ -1,5 +1,9 @@
package morlok8k.MinecraftLandGenerator;
/**
*
* @author morlok8k
*/
public class Time {
/**
@ -68,6 +72,7 @@ public class Time {
/**
* waits ten seconds. outputs 10%, 20%, etc after each second.
*
* @param output
* @author Morlok8k
*/
public static void waitTenSec(final boolean output) {
@ -97,5 +102,4 @@ public class Time {
return;
}
}

View File

@ -16,6 +16,10 @@ import java.util.Iterator;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
*
* @author morlok8k
*/
public class Update {
/**
@ -29,6 +33,7 @@ public class Update {
* <br>
* This saves the hash and the timestamp (now known as the BuildID)
*
* @param downloadOnly
* @author Morlok8k
*/
public static void buildID(final boolean downloadOnly) {
@ -140,6 +145,9 @@ public class Update {
/**
* This gets the filename of a .jar (typically this one!)
*
* @param classFile
* @return
* @throws IOException
* @author Morlok8k
*/
public static String getClassLoader(final Class<?> classFile) throws IOException {
@ -182,6 +190,9 @@ public class Update {
* Thanks to Roedy Green at <br>
* <a href="http://mindprod.com/jgloss/compiletimestamp.html">http://mindprod .com/jgloss/compiletimestamp.html</a>
*
* @param classFile
* @return
* @throws IOException
* @author Morlok8k
*/
public static Date getCompileTimeStamp(final Class<?> classFile) throws IOException {
@ -434,7 +445,7 @@ public class Update {
* <a href="http://www.java-examples.com/get-crc-32-checksum-zip-entry-example">http://www.java-examples.com/get-crc-32-checksum-zip-entry-example</a>
*
* @param zipFile
* @param timeBuildID
* @return
* @author Morlok8k
*/
public static Long ZipGetModificationTime(final String zipFile) {
@ -489,5 +500,4 @@ public class Update {
return 0L; //return Jan. 1, 1970 12:00 GMT for failures
}
}
}

View File

@ -8,6 +8,10 @@ import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author morlok8k
*/
public class WorldVerify {
/**
@ -85,5 +89,4 @@ public class WorldVerify {
}
}
}

View File

@ -7,118 +7,308 @@ import java.util.Date;
import java.util.Locale;
import java.util.Scanner;
/**
*
* @author morlok8k
*/
public class var {
//
// Program Info:
/**
*
*/
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 VERSION = "1.7.1 test 10"; // Version Number!
/**
*
*/
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 newLine = System.getProperty("line.separator");
//
// Commonly Used Strings:
/**
*
*/
public static String MLG = "[MLG] ";
/**
*
*/
public static String MLGe = "[MLG-ERROR] ";
//
// Date & Build-ID stuff:
/**
*
*/
public static DateFormat dateFormat_MDY = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH);
/**
*
*/
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 final String MinecraftLandGeneratorConf = "MinecraftLandGenerator.conf";
/**
*
*/
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 preparingText = null;
/**
*
*/
public static String preparingLevel = null;
/**
*
*/
public static String level_0 = null; // the world
/**
*
*/
public static String level_1 = null; // the nether
/**
*
*/
public static String level_2 = null; // the end
/**
*
*/
public static String level_3 = null; // future worlds
/**
*
*/
public static String level_4 = null;
/**
*
*/
public static String level_5 = null;
/**
*
*/
public static String level_6 = null;
/**
*
*/
public static String level_7 = null;
/**
*
*/
public static String level_8 = null;
/**
*
*/
public static String level_9 = null;
/**
*
*/
public static final String defaultJavaLine =
"java -Djava.awt.headless=true -Djline.terminal=jline.UnsupportedTerminal -Duser.language=en"
+ " -Xms1024m -Xmx1024m -Xincgc -jar minecraft_server.jar nogui";
/**
*
*/
public static String serverPath = 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 boolean waitSave = false;
/**
*
*/
public static boolean ignoreWarnings = false;
/**
*
*/
public static Long randomSeed = (long) 0;
//
// Update URLs:
/**
*
*/
public static final String github_URL =
"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_BuildID_URL = github_URL + buildIDFile;
/**
*
*/
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 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 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 incrementFull = (int) (Math.sqrt(MinecraftServerChunkPlayerCache) * 16); // 400, the length of a fresh (no players have ever logged in) server map.
/**
*
*/
public static int increment = incrementFull - 16; //public static int increment = 384; // 384, what we use to iterate between sections of the map. Allows for some overlap to prevent "stripes"
/**
*
*/
public static boolean assertsEnabled = false; //debugging use... use java -ea -jar MinecraftlandGenerator.jar...
/**
*
*/
public static long startTime = 0L;
/**
*
*/
public static Boolean recheckFlag = false;
}

View File

@ -1,5 +1,9 @@
package org.w3c.bert_bos.UTF8URL;
/**
*
* @author morlok8k
*/
public class Unescape {
/* Morlok8k:
@ -28,7 +32,6 @@ public class Unescape {
* @return decoded string of URL
* @author Bert Bos
*/
public static String unescape(final String s) {
final StringBuffer sbuf = new StringBuffer();
final int l = s.length();