diff --git a/src/corrodias/minecraft/landgenerator/Main.java b/src/corrodias/minecraft/landgenerator/Main.java index c1ad869..504cfb5 100644 --- a/src/corrodias/minecraft/landgenerator/Main.java +++ b/src/corrodias/minecraft/landgenerator/Main.java @@ -131,9 +131,16 @@ public class Main { private static Boolean recheckFlag = false; private static long startTime = 0L; + private static boolean useRCON = false; //use RCON to communicate with server. ***Experimental*** + @SuppressWarnings("unused") + private static boolean rcon_Enabled = false; //is server is set to use RCON? + public static String rcon_IPaddress = "0.0.0.0"; //default is 0.0.0.0 + public static String rcon_Port = "25575"; //default is 25575, we are just initializing here. + public static String rcon_Password = "test"; //default is "", but a password must be entered. + ////// - public static final boolean testing = false; // display more output when debugging + public static final boolean testing = false; // display more output when debugging ////// @@ -400,6 +407,15 @@ public class Main { xOffset = Integer.valueOf(args[i + 2].substring(2)); out("Notice: X Offset: " + xOffset); + } else if (nextSwitch.startsWith("-rcon")) { + if (testing) { + useRCON = true; + out("Notice: Attempting to use RCON to communicate with server..."); + } else { + useRCON = false; + err("MLG Using RCON is not enabled yet."); + } + } else if (nextSwitch.startsWith("-y") || nextSwitch.startsWith("-z")) { //NOTE: "-y" is just here for backwards compatibility zOffset = Integer.valueOf(args[i + 2].substring(2)); out("Notice: Z Offset: " + zOffset); @@ -1577,6 +1593,9 @@ public class Main { File config = new File(MinecraftLandGeneratorConf); BufferedReader in = new BufferedReader(new FileReader(config)); String line; + String property; + String value; + while ((line = in.readLine()) != null) { int pos = line.indexOf('='); int end = line.lastIndexOf('#'); // comments, ignored lines @@ -1588,40 +1607,42 @@ public class Main { end = line.length(); } + property = line.substring(0, pos).toLowerCase(); + value = line.substring(pos + 1, end); + if (pos != -1) { - if (line.substring(0, pos).toLowerCase().equals("serverpath")) { - serverPath = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("java")) { - javaLine = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("done_text")) { - doneText = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("preparing_text")) { - preparingText = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("preparing_level")) { - preparingLevel = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("level-0")) { - level_0 = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("level-1")) { - level_1 = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("level-2")) { - level_2 = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("level-3")) { - level_3 = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("level-4")) { - level_4 = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("level-5")) { - level_5 = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("level-6")) { - level_6 = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("level-7")) { - level_7 = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("level-8")) { - level_8 = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("level-9")) { - level_9 = line.substring(pos + 1, end); - } else if (line.substring(0, pos).toLowerCase().equals("waitsave")) { - String wstmp = line.toLowerCase().substring(pos + 1, end); - if (wstmp.equals("true")) { + if (property.equals("serverpath")) { + serverPath = value; + } else if (property.equals("java")) { + javaLine = value; + } else if (property.equals("done_text")) { + doneText = value; + } else if (property.equals("preparing_text")) { + preparingText = value; + } else if (property.equals("preparing_level")) { + preparingLevel = value; + } else if (property.equals("level-0")) { + level_0 = value; + } else if (property.equals("level-1")) { + level_1 = value; + } else if (property.equals("level-2")) { + level_2 = value; + } else if (property.equals("level-3")) { + level_3 = value; + } else if (property.equals("level-4")) { + level_4 = value; + } else if (property.equals("level-5")) { + level_5 = value; + } else if (property.equals("level-6")) { + level_6 = value; + } else if (property.equals("level-7")) { + level_7 = value; + } else if (property.equals("level-8")) { + level_8 = value; + } else if (property.equals("level-9")) { + level_9 = value; + } else if (property.equals("waitsave")) { + if (value.toLowerCase().equals("true")) { waitSave = true; } else { waitSave = false; @@ -1737,10 +1758,53 @@ public class Main { String line; while ((line = props.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(); + } + if (pos != -1) { - if (line.substring(0, pos).toLowerCase().equals("level-name")) { - worldPath = serverPath + fileSeparator + line.substring(pos + 1); - worldName = line.substring(pos + 1); + + String property = line.substring(0, pos).toLowerCase(); + String value = line.substring(pos + 1); + + if (property.equals("level-name")) { + worldPath = serverPath + fileSeparator + value; + worldName = value; + } + if (useRCON) { + if (property.equals("enable-rcon")) { + + if (value.contains("true")) { + rcon_Enabled = true; + out("RCON is set to be Enabled on the server."); + } else { + rcon_Enabled = false; + useRCON = false; + err("RCON is not Enabled on the server."); + } + } else if (property.equals("rcon.password")) { + rcon_Password = value; + if (rcon_Password.isEmpty()) { + useRCON = false; + err("RCON Needs a password!."); + } + out("RCON Password:" + rcon_Password); + } else if (property.equals("rcon.port")) { + rcon_Port = value; + out("RCON Port:" + rcon_Port); + } else if (property.equals("server-ip")) { + String IP = value; + if (IP.isEmpty()) { + IP = "0.0.0.0"; + } + rcon_IPaddress = IP; + + } } } diff --git a/src/morlok8k/minecraft/landgenerator/Readme_and_HelpInfo.java b/src/morlok8k/minecraft/landgenerator/Readme_and_HelpInfo.java index 2ad76bb..c76ae65 100644 --- a/src/morlok8k/minecraft/landgenerator/Readme_and_HelpInfo.java +++ b/src/morlok8k/minecraft/landgenerator/Readme_and_HelpInfo.java @@ -67,6 +67,7 @@ public class Readme_and_HelpInfo { + "- Updated Time Output again. Now says \"1 Minute\" instead of \"1 Minutes\"." + 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." + newLine + "- Added \"-nowait\" and its shorter version \"-n\"" + newLine + + "- Added currently non-functional RCON code. Will try to make functional in the future." + newLine + newLine + "1.6.11" + newLine + "- Removed End-of-Generation ASCII-Graphic - It didn't really fit with MLG." + newLine diff --git a/src/morlok8k/minecraft/landgenerator/rcon_MLG.java b/src/morlok8k/minecraft/landgenerator/rcon_MLG.java new file mode 100644 index 0000000..e3e83fc --- /dev/null +++ b/src/morlok8k/minecraft/landgenerator/rcon_MLG.java @@ -0,0 +1,44 @@ +package morlok8k.minecraft.landgenerator; + +import corrodias.minecraft.landgenerator.Main; + +public class rcon_MLG { + + /** + * connects to server using RCON, sends a message, and disconnects. Not Functional yet. + * + * @param message + */ + @SuppressWarnings("unused") + private static void rconConnectAndSendMsg(String message) { + //This is a placeholder for future code. + /* + step 1: connect to rcon_IPaddress : rcon_Port, with rcon_Password. + step 2: send message (probably "stop" or "save-all") + step 3: disconnect. + */ + Main.out("Connect to Server: " + Main.rcon_IPaddress + ":" + Main.rcon_Port + " Password: " + + Main.rcon_Password); + + return; + } + + /** + * Queries the server using RCON to see if we can connect. Not functional yet. + * + * @return QuerySucess + */ + @SuppressWarnings("unused") + private static boolean rconQueryServer() { + boolean QuerySucess = false; + + //This is a placeholder for future code. + /* + step 1: query rcon_IPaddress : rcon_Port + step 2: return true or false if successful or not. + */ + Main.out("Query Server: " + Main.rcon_IPaddress + ":" + Main.rcon_Port); + + return QuerySucess; + } +} diff --git a/update_github.sh b/update_github.sh index f27b616..eaaaebf 100755 --- a/update_github.sh +++ b/update_github.sh @@ -1,7 +1,7 @@ #!/bin/sh ## Minecraft Land Generator - GitHub Update Script -## Morlok8k - Updated 4/15/2012 +## Morlok8k - Updated 5/28/2012 zip -r ./bin/MinecraftLandGenerator.jar ./src/