From 3a36fe2013bbed04adf475233aa268bb4886de6a Mon Sep 17 00:00:00 2001 From: sommerlilie Date: Tue, 13 Nov 2018 19:14:16 +0100 Subject: [PATCH] Added picocli --- .idea/workspace.xml | 267 ++++---- MLG-BuildID | 2 +- .../CommandLineMain.java | 51 ++ .../MinecraftLandGenerator/Coordinates.java | 604 +++++++++--------- .../morlok8k/MinecraftLandGenerator/Main.java | 1 - 5 files changed, 491 insertions(+), 434 deletions(-) create mode 100644 src/main/java/morlok8k/MinecraftLandGenerator/CommandLineMain.java diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c838e33..1b43e6e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,11 @@ + + + - + @@ -17,41 +20,45 @@ - + - + + + - + - + + - + + - + - + @@ -62,11 +69,8 @@ - - - - - + + @@ -74,7 +78,7 @@ - + @@ -83,7 +87,7 @@ - + @@ -92,20 +96,8 @@ - - - - - - - - - - - - - - + + @@ -113,8 +105,21 @@ - - + + + + + + + + + + + + + + + @@ -122,24 +127,8 @@ - - - - - - - - - - - - - - - - - - + + @@ -147,17 +136,26 @@ - + - + - - + + + + + + + + + + + @@ -231,9 +229,10 @@ @@ -283,7 +282,7 @@ - @@ -464,6 +469,9 @@ + + + @@ -482,20 +490,20 @@ - - + - + @@ -505,7 +513,7 @@ - + @@ -651,9 +659,6 @@ - - - @@ -668,16 +673,6 @@ - - - - - - - - - - @@ -692,9 +687,6 @@ - - - @@ -705,47 +697,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -753,37 +704,93 @@ - + - - + + - + - + - - + + + + + + + + + + + + + + + + - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + diff --git a/MLG-BuildID b/MLG-BuildID index c3b0c8d..8fe0c9c 100644 --- a/MLG-BuildID +++ b/MLG-BuildID @@ -67,4 +67,4 @@ EC40B0ECC52B37571EE65F780994CEDE=1360299846000# MLG v1.7.3 750641846428072595BB3D7657AC8EB1=1373344097000# MLG v1.7.4 2ADFF46BCF1E77A559E6D9DB9C7586E8=1381398906000# MLG v1.7.5 3223FFFEE274215C50C88372D79B9E5C=1421666774000# MLG v1.7.6 -72E64BD3C21E559B909A995F38E92C24=1542019123000# MLG v1.7.7 (Class File, Not .Jar) +0E579FCDFAC99EE49E3C11D26FFDC3C6=1542129713000# MLG v1.7.7 (Class File, Not .Jar) diff --git a/src/main/java/morlok8k/MinecraftLandGenerator/CommandLineMain.java b/src/main/java/morlok8k/MinecraftLandGenerator/CommandLineMain.java new file mode 100644 index 0000000..25ccaba --- /dev/null +++ b/src/main/java/morlok8k/MinecraftLandGenerator/CommandLineMain.java @@ -0,0 +1,51 @@ +package morlok8k.MinecraftLandGenerator; + +import picocli.CommandLine.Option; +import picocli.CommandLine.Parameters; +import picocli.CommandLine; +import picocli.CommandLine.RunLast; +import picocli.CommandLine.Command; +import picocli.CommandLine.HelpCommand; + +import java.nio.file.Path; +@Command(name = "mgl", subcommands = { + HelpCommand.class}) + +public class CommandLineMain implements Runnable{ + @Option(names = {"-v", "--verbose"}, description = "Be verbose.") + private boolean verbose = false; + + @Parameters(index = "0", description = "X-coordinate") + private int X; + + @Parameters(index = "1", description = "Z-coordinate") + private int Z; + + @Parameters(index = "2", description = "path to the directory in which the server runs") + private Path serverPath; + + @Option(names = "-i", description = "override the iteration spawn offset increment") + private int increment = 380; + + @Option(names = "-i", description = "set the X offset to generate land around") + private int xOffset = 0; + + @Option(names = "-i", description = "set the Z offset to generate land around") + private int zOffset = 0; + + + + public CommandLineMain(){ + + } + @Override + public void run() { + CommandLine.usage(this, System.err); + } + + public static void main(String[] args) { + CommandLine cli = new CommandLine(new CommandLineMain()); + cli.parseWithHandler(new RunLast(), args); + } + +} diff --git a/src/main/java/morlok8k/MinecraftLandGenerator/Coordinates.java b/src/main/java/morlok8k/MinecraftLandGenerator/Coordinates.java index a15ad12..2e02e80 100644 --- a/src/main/java/morlok8k/MinecraftLandGenerator/Coordinates.java +++ b/src/main/java/morlok8k/MinecraftLandGenerator/Coordinates.java @@ -1,302 +1,302 @@ -/* - * ####################################################################### # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # # Version 2, December 2004 # # # # Copyright (C) 2004 Sam Hocevar - * # # # # Everyone is permitted to copy and distribute verbatim or modified # # copies of this license document, and changing it is allowed as long # # as the name is changed. # # # - * # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION # # # # 0. You just DO WHAT THE FUCK YOU WANT TO. # # # - * ####################################################################### - */ - -//package morlok8k.MinecraftLandGenerator; - -import org.joml.Vector3i; - -/** - * Coordinates are in the form of [X,Y,Z] or (X,Z)
- *
- * x-axis (longitude): the distance east (positive) or west (negative) of the origin point
- * z-axis (latitude): the distance south (positive) or north (negative) of the origin point
- * y-axis (elevation): how high or low (from 0 to 255 (previously 128), with 64 being sea level)
- * The origin point: When both X and Z are both zero. (elevation is irrelevant)
- */ -//public class Coordinates { -/* - - */ -/** - * Parses a Coordinates object from a String. Leading and trailing garbage is ignored (FIXME). - * - * @param StringOfCoords A short- or long-form coordinate string as described at the two toString() methods - * @return - * @author Morlok8k - *//* - - -*/ -/* public static Vector3i parseString(String StringOfCoords) { - //parse out string - StringOfCoords = StringOfCoords.trim(); - - int x = 0, y = 0, z = 0; - - int start, end; - String sX = "", sY = "", sZ = ""; - boolean shortMode = false, notCoords = false; - - start = StringOfCoords.indexOf("["); - end = StringOfCoords.indexOf("]"); - - if ((start == -1) || (end == -1)) { - start = StringOfCoords.indexOf("("); - end = StringOfCoords.indexOf(")"); - - if ((start != -1) && (end != -1)) { - shortMode = true; - } else { - notCoords = true; - } - } - - if (notCoords) { - return new Vector3i(0, 0, 0); - } - - String[] coords = StringOfCoords.substring(start, end).split(","); - if (shortMode) { - return new Vector3i(Integer.valueOf(coords[0]), 64, Integer.valueOf(coords[2])); - // sX = StringOfCoords.substring(start + 1, firstComma); - // sY = "64"; - // sZ = StringOfCoords.substring(firstComma + 1, end); - - } else { - return new Vector3i(Integer.valueOf(coords[0]), Integer.valueOf(coords[1]), Integer.valueOf(coords[2])); - // StringOfCoords = StringOfCoords.substring(start, end); - - // firstComma = StringOfCoords.indexOf(","); - // secComma = StringOfCoords.lastIndexOf(","); - - // sX = StringOfCoords.substring(start + 1, firstComma); - // sY = StringOfCoords.substring(firstComma + 1, secComma); - // sZ = StringOfCoords.substring(secComma + 1, end); - - } - - //try { - // x = Integer.parseInt(sX); - // y = Integer.parseInt(sY); - // z = Integer.parseInt(sZ); - //} catch (final NumberFormatException e) { - // return new Coordinates(0, 0, 0); - //} - - //return new Coordinates(x, y, z); - } - - /** - * - *//* - -*/ -/* public int X = 0; - /** - * - *//* - - public int Y = 0; - */ -/** - * - *//* - - public int Z = 0; - - */ -/** - * Someone created a new blank Coordinate! Lets set it to be [0,0,0]. - *//* - - public Coordinates() { - clear(); - } - - */ -/** - * @param x - * @param y - * @param z - *//* - - public Coordinates(final int x, final int y, final int z) { - super(); - X = x; - Y = y; - Z = z; - } - - */ -/** - * - *//* - - public void clear() { - X = 0; - Y = 0; - Z = 0; - } - - */ -/* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - *//* - - @SuppressWarnings({"unused", "null"}) - @Override - public boolean equals(final Object obj) { - // I am overriding the inherited equals method. - // Because it doesn't know how to deal with my custom data. - // So instead of always failing, it actually works! - // (by default it gets the memory addresses of each object.) - - // An object must equal itself - if (this == obj) { - return true; - } - - // No object equals null - if (obj == null) { - return false; - } - if (this == null) { - return false; - } - - // Objects of different types are never equal - if (getClass() != obj.getClass()) { - return false; - } - - // Cast to an Coordinates, then compare the data - final Coordinates c = (Coordinates) obj; - if (X != c.X) { - return false; - } - if (Y != c.Y) { - return false; - } - if (Z != c.Z) { - return false; - } - return true; // If none of the above returned something, they must be equal! - } - - */ -/** - * @return the x - *//* - - public int getX() { - return X; - } - - */ -/** - * @return the y - *//* - - public int getY() { - return Y; - } - - */ -/** - * @return the z - *//* - - public int getZ() { - return Z; - } - - */ -/* (non-Javadoc) - * @see java.lang.Object#hashCode() - *//* - - @Override - public int hashCode() { - // I am overriding the inherited hashCode method. - // Because it doesn't know how to deal with my custom data. - // So instead of getting who knows what, we return valid data - - final int prime = 31; // My hard coded prime number - int result = 1; // The hard coded number I start with - result = (prime * result) + X; // Add the X data - result = (prime * result) + Y; // Add the Y data - result = (prime * result) + Z; // Add the Z data - return result; //this result will consistently give the same result for the same data. - // [0,0,0] will always give 29791. [1,2,3] will always give 30817. - //yes, If I was lazy, I could just do a "return 0;" and it would still be technically valid. - //but if I'm going override the method, I might as well do it right... - } - - */ -/** - * @param x the x to set - *//* - - public void setX(final int x) { - X = x; - } - - /////////////////////////////////////////////////////////////////////////////////////// - // Java Language Specific Crap Below... Stuff *gotta* be there so Java won't cry... // - /////////////////////////////////////////////////////////////////////////////////////// - - */ -/** - * @param y the y to set - *//* - - public void setY(final int y) { - Y = y; - } - - */ -/** - * @param z the z to set - *//* - - public void setZ(final int z) { - Z = z; - } - - */ -/* (non-Javadoc) - * @see java.lang.Object#toString() - *//* - - @Override - public String toString() { - // I am overriding the inherited toString method. - // Because it doesn't know how to deal with my custom data. - // So instead of getting "blahblahblah.Coordinates@745f" - // (the location of the class and the hexstring of the hashcode) - // I return "[X,Y,Z]" - - return ("[" + X + "," + Y + "," + Z + "]"); - - } - - */ -/** - * @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)") - } - return toString(); // Idiot catch. default to: "[X,Y,Z]" - - } - -*/ -//} +///* +// * ####################################################################### # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # # Version 2, December 2004 # # # # Copyright (C) 2004 Sam Hocevar +// * # # # # Everyone is permitted to copy and distribute verbatim or modified # # copies of this license document, and changing it is allowed as long # # as the name is changed. # # # +// * # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION # # # # 0. You just DO WHAT THE FUCK YOU WANT TO. # # # +// * ####################################################################### +// */ +// +////package morlok8k.MinecraftLandGenerator; +// +//import org.joml.Vector3i; +// +///** +// * Coordinates are in the form of [X,Y,Z] or (X,Z)
+// *
+// * x-axis (longitude): the distance east (positive) or west (negative) of the origin point
+// * z-axis (latitude): the distance south (positive) or north (negative) of the origin point
+// * y-axis (elevation): how high or low (from 0 to 255 (previously 128), with 64 being sea level)
+// * The origin point: When both X and Z are both zero. (elevation is irrelevant)
+// */ +////public class Coordinates { +///* +// +// */ +///** +// * Parses a Coordinates object from a String. Leading and trailing garbage is ignored (FIXME). +// * +// * @param StringOfCoords A short- or long-form coordinate string as described at the two toString() methods +// * @return +// * @author Morlok8k +// *//* +// +// +//*/ +///* public static Vector3i parseString(String StringOfCoords) { +// //parse out string +// StringOfCoords = StringOfCoords.trim(); +// +// int x = 0, y = 0, z = 0; +// +// int start, end; +// String sX = "", sY = "", sZ = ""; +// boolean shortMode = false, notCoords = false; +// +// start = StringOfCoords.indexOf("["); +// end = StringOfCoords.indexOf("]"); +// +// if ((start == -1) || (end == -1)) { +// start = StringOfCoords.indexOf("("); +// end = StringOfCoords.indexOf(")"); +// +// if ((start != -1) && (end != -1)) { +// shortMode = true; +// } else { +// notCoords = true; +// } +// } +// +// if (notCoords) { +// return new Vector3i(0, 0, 0); +// } +// +// String[] coords = StringOfCoords.substring(start, end).split(","); +// if (shortMode) { +// return new Vector3i(Integer.valueOf(coords[0]), 64, Integer.valueOf(coords[2])); +// // sX = StringOfCoords.substring(start + 1, firstComma); +// // sY = "64"; +// // sZ = StringOfCoords.substring(firstComma + 1, end); +// +// } else { +// return new Vector3i(Integer.valueOf(coords[0]), Integer.valueOf(coords[1]), Integer.valueOf(coords[2])); +// // StringOfCoords = StringOfCoords.substring(start, end); +// +// // firstComma = StringOfCoords.indexOf(","); +// // secComma = StringOfCoords.lastIndexOf(","); +// +// // sX = StringOfCoords.substring(start + 1, firstComma); +// // sY = StringOfCoords.substring(firstComma + 1, secComma); +// // sZ = StringOfCoords.substring(secComma + 1, end); +// +// } +// +// //try { +// // x = Integer.parseInt(sX); +// // y = Integer.parseInt(sY); +// // z = Integer.parseInt(sZ); +// //} catch (final NumberFormatException e) { +// // return new Coordinates(0, 0, 0); +// //} +// +// //return new Coordinates(x, y, z); +// } +// +// /** +// * +// *//* +// +//*/ +///* public int X = 0; +// /** +// * +// *//* +// +// public int Y = 0; +// */ +///** +// * +// *//* +// +// public int Z = 0; +// +// */ +///** +// * Someone created a new blank Coordinate! Lets set it to be [0,0,0]. +// *//* +// +// public Coordinates() { +// clear(); +// } +// +// */ +///** +// * @param x +// * @param y +// * @param z +// *//* +// +// public Coordinates(final int x, final int y, final int z) { +// super(); +// X = x; +// Y = y; +// Z = z; +// } +// +// */ +///** +// * +// *//* +// +// public void clear() { +// X = 0; +// Y = 0; +// Z = 0; +// } +// +// */ +///* (non-Javadoc) +// * @see java.lang.Object#equals(java.lang.Object) +// *//* +// +// @SuppressWarnings({"unused", "null"}) +// @Override +// public boolean equals(final Object obj) { +// // I am overriding the inherited equals method. +// // Because it doesn't know how to deal with my custom data. +// // So instead of always failing, it actually works! +// // (by default it gets the memory addresses of each object.) +// +// // An object must equal itself +// if (this == obj) { +// return true; +// } +// +// // No object equals null +// if (obj == null) { +// return false; +// } +// if (this == null) { +// return false; +// } +// +// // Objects of different types are never equal +// if (getClass() != obj.getClass()) { +// return false; +// } +// +// // Cast to an Coordinates, then compare the data +// final Coordinates c = (Coordinates) obj; +// if (X != c.X) { +// return false; +// } +// if (Y != c.Y) { +// return false; +// } +// if (Z != c.Z) { +// return false; +// } +// return true; // If none of the above returned something, they must be equal! +// } +// +// */ +///** +// * @return the x +// *//* +// +// public int getX() { +// return X; +// } +// +// */ +///** +// * @return the y +// *//* +// +// public int getY() { +// return Y; +// } +// +// */ +///** +// * @return the z +// *//* +// +// public int getZ() { +// return Z; +// } +// +// */ +///* (non-Javadoc) +// * @see java.lang.Object#hashCode() +// *//* +// +// @Override +// public int hashCode() { +// // I am overriding the inherited hashCode method. +// // Because it doesn't know how to deal with my custom data. +// // So instead of getting who knows what, we return valid data +// +// final int prime = 31; // My hard coded prime number +// int result = 1; // The hard coded number I start with +// result = (prime * result) + X; // Add the X data +// result = (prime * result) + Y; // Add the Y data +// result = (prime * result) + Z; // Add the Z data +// return result; //this result will consistently give the same result for the same data. +// // [0,0,0] will always give 29791. [1,2,3] will always give 30817. +// //yes, If I was lazy, I could just do a "return 0;" and it would still be technically valid. +// //but if I'm going override the method, I might as well do it right... +// } +// +// */ +///** +// * @param x the x to set +// *//* +// +// public void setX(final int x) { +// X = x; +// } +// +// /////////////////////////////////////////////////////////////////////////////////////// +// // Java Language Specific Crap Below... Stuff *gotta* be there so Java won't cry... // +// /////////////////////////////////////////////////////////////////////////////////////// +// +// */ +///** +// * @param y the y to set +// *//* +// +// public void setY(final int y) { +// Y = y; +// } +// +// */ +///** +// * @param z the z to set +// *//* +// +// public void setZ(final int z) { +// Z = z; +// } +// +// */ +///* (non-Javadoc) +// * @see java.lang.Object#toString() +// *//* +// +// @Override +// public String toString() { +// // I am overriding the inherited toString method. +// // Because it doesn't know how to deal with my custom data. +// // So instead of getting "blahblahblah.Coordinates@745f" +// // (the location of the class and the hexstring of the hashcode) +// // I return "[X,Y,Z]" +// +// return ("[" + X + "," + Y + "," + Z + "]"); +// +// } +// +// */ +///** +// * @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)") +// } +// return toString(); // Idiot catch. default to: "[X,Y,Z]" +// +// } +// +//*/ +////} diff --git a/src/main/java/morlok8k/MinecraftLandGenerator/Main.java b/src/main/java/morlok8k/MinecraftLandGenerator/Main.java index ee8c344..14b9c6b 100644 --- a/src/main/java/morlok8k/MinecraftLandGenerator/Main.java +++ b/src/main/java/morlok8k/MinecraftLandGenerator/Main.java @@ -27,7 +27,6 @@ import java.awt.EventQueue; import java.io.File; import java.io.IOException; import java.net.URI; -import java.nio.file.Files; import java.util.ArrayList; import java.util.Iterator; import java.util.logging.Level;