1.7.0 (Finally! Now to add things for 1.7.1! *Sigh*)

This commit is contained in:
Morlok8k 2012-08-10 03:16:20 -07:00
parent fc3a2121b9
commit a2da3bae4a
50 changed files with 835 additions and 793 deletions

View File

@ -1,4 +1,56 @@
#Wed Nov 02 01:36:56 PDT 2011 cleanup.add_default_serial_version_id=false
cleanup.add_generated_serial_version_id=true
cleanup.add_missing_annotations=true
cleanup.add_missing_deprecated_annotations=true
cleanup.add_missing_methods=true
cleanup.add_missing_nls_tags=false
cleanup.add_missing_override_annotations=true
cleanup.add_missing_override_annotations_interface_methods=true
cleanup.add_serial_version_id=true
cleanup.always_use_blocks=true
cleanup.always_use_parentheses_in_expressions=true
cleanup.always_use_this_for_non_static_field_access=false
cleanup.always_use_this_for_non_static_method_access=false
cleanup.convert_to_enhanced_for_loop=false
cleanup.correct_indentation=true
cleanup.format_source_code=true
cleanup.format_source_code_changes_only=false
cleanup.make_local_variable_final=true
cleanup.make_parameters_final=true
cleanup.make_private_fields_final=true
cleanup.make_type_abstract_if_missing_method=false
cleanup.make_variable_declarations_final=true
cleanup.never_use_blocks=false
cleanup.never_use_parentheses_in_expressions=false
cleanup.organize_imports=true
cleanup.qualify_static_field_accesses_with_declaring_class=false
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
cleanup.qualify_static_member_accesses_with_declaring_class=true
cleanup.qualify_static_method_accesses_with_declaring_class=false
cleanup.remove_private_constructors=true
cleanup.remove_trailing_whitespaces=true
cleanup.remove_trailing_whitespaces_all=true
cleanup.remove_trailing_whitespaces_ignore_empty=false
cleanup.remove_unnecessary_casts=true
cleanup.remove_unnecessary_nls_tags=true
cleanup.remove_unused_imports=true
cleanup.remove_unused_local_variables=false
cleanup.remove_unused_private_fields=true
cleanup.remove_unused_private_members=false
cleanup.remove_unused_private_methods=true
cleanup.remove_unused_private_types=true
cleanup.sort_members=false
cleanup.sort_members_all=false
cleanup.use_blocks=true
cleanup.use_blocks_only_for_return_and_throw=false
cleanup.use_parentheses_in_expressions=true
cleanup.use_this_for_non_static_field_access=true
cleanup.use_this_for_non_static_field_access_only_if_necessary=true
cleanup.use_this_for_non_static_method_access=true
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup_profile=_Morlok8k
cleanup_settings_version=2
eclipse.preferences.version=1 eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_Morlok8k formatter_profile=_Morlok8k

153
README
View File

@ -1,10 +1,10 @@
Minecraft Land Generator version 1.6.3 Minecraft Land Generator version 1.7.0
Updated June 12, 2012 Updated August 10, 2012
(BuildID: 1339559312000) (BuildID: 1344593776000)
Original Code by Corrodias November 2010 Original Code by Corrodias November 2010
Enhanced Code by Morlok8k Feb. 2011 to Now (or at least to June 12, 2012!) Enhanced Code by Morlok8k Feb. 2011 to Now (or at least to August 10, 2012!)
Additional Code by pr0f1x October 2011 Additional Code by pr0f1x October 2011
Website: https://sites.google.com/site/minecraftlandgenerator/ Website: https://sites.google.com/site/minecraftlandgenerator/
@ -25,8 +25,85 @@ The "unescape" method/function is also not Public Domain. Its License is the W3
Other Public Domain code has been used in this program, and references to sources are included in the comments of Minecraft Land Generator's source code. Other Public Domain code has been used in this program, and references to sources are included in the comments of Minecraft Land Generator's source code.
----------------------------------------------- -----------------------------------------------
Usage: java -jar MinecraftLandGenerator.jar x z [serverpath] [switches]
Arguments:
x : X range to generate
z : Z range to generate
serverpath : the path to the directory in which the server runs (takes precedence over the config file setting)
Switches:
-verbose : causes the application to output the server's messages to the console
-v : same as -verbose
-w : Ignore [WARNING] and [SEVERE] messages.
-alt : alternate server launch sequence
-a : same as -alt
-nowait : don't pause for anything
-n : same as -nowait
-i# : override the iteration spawn offset increment (default 380) (example: -i100)
-x# : set the X offset to generate land around (example: -x0 or -x1000 or -x-500)
-z# : set the Z offset to generate land around (example: -z0 or -z1000 or -z-500)
Other options:
java -jar MinecraftLandGenerator.jar -update
Checks for and downloads new versions of MLG online.
java -jar MinecraftLandGenerator.jar -printspawn
java -jar MinecraftLandGenerator.jar -ps
Outputs the current world's spawn point coordinates.
java -jar MinecraftLandGenerator.jar -conf
java -jar MinecraftLandGenerator.jar -conf download
Generates or downloads a MinecraftLandGenerator.conf file.
java -jar MinecraftLandGenerator.jar -readme readme.txt
java -jar MinecraftLandGenerator.jar -readme
Generates a readme file using supplied name or the default _MLG_Readme.txt
java -jar MinecraftLandGenerator.jar -downloadfile http://example.com/file.txt
Downloads whatever file from the internet you give it.
java -jar MinecraftLandGenerator.jar -downloadlist list.txt
list.txt (or any other file) contains a URL on each line which will be downloaded.
java -jar MinecraftLandGenerator.jar -version
java -jar MinecraftLandGenerator.jar -help
java -jar MinecraftLandGenerator.jar /?
Prints this message.
When launched with the -conf switch, this application creates a MinecraftLandGenerator.conf file that contains configuration options.
If this file does not exist or does not contain all required properties, the application will not run.
MinecraftLandGenerator.conf properties:
Java : The command line to use to launch the server
ServerPath : The path to the directory in which the server runs (can be overridden by the serverpath argument)
Done_Text : The output from the server that tells us that we are done
Preparing_Text : The output from the server that tells us the percentage
Preparing_Level : The output from the server that tells us the level it is working on
Level-0 : Name of Level 0: The Overworld
Level-1 : Name of Level 1: The Nether
Level-2 : Name of Level 2: The End
Level-3 : Name of Level 3: (Future Level)
Level-4 : Name of Level 4: (Future Level)
Level-5 : Name of Level 5: (Future Level)
Level-6 : Name of Level 6: (Future Level)
Level-7 : Name of Level 7: (Future Level)
Level-8 : Name of Level 8: (Future Level)
Level-9 : Name of Level 9: (Future Level)
WaitSave : Optional: Wait before saving.
-----------------------------------------------
Version History: Version History:
Morlok8k: Morlok8k:
1.7.0
- Major Code Optimization
- Drastically reduced the amount of time it takes for MLG to expand a world after it has already done so before!
(To do this, I rewrote the Main loop of the program, and add my own Coordinate object)
- Added Resume Functionality
- Updated Time Output yet again.
- Made xx% output nicer by rewriting previous existing line.
- Misc. Tweaks
- Misc. Additions
1.6.3 1.6.3
- Minor Code Optimization - Minor Code Optimization
- Finely got on the ball and added the JNBT source and everything (as an internal .zip) to be completely faithful to his license - Finely got on the ball and added the JNBT source and everything (as an internal .zip) to be completely faithful to his license
@ -151,71 +228,3 @@ Notes:
Due to changes in server beta 1.6, it now generates the nether as well as the world at the same time. Due to changes in server beta 1.6, it now generates the nether as well as the world at the same time.
However, Since beta 1.9 and Minecraft 1.0, the nether or the end is no longer generated.I recommend using MCEDIT to relight the map after you generate it. This will take a long time, but should fix all those incorrectly dark spots in your level. However, Since beta 1.9 and Minecraft 1.0, the nether or the end is no longer generated.I recommend using MCEDIT to relight the map after you generate it. This will take a long time, but should fix all those incorrectly dark spots in your level.
-----------------------------------------------
Usage: java -jar MinecraftLandGenerator.jar x z [serverpath] [switches]
Arguments:
x : X range to generate
z : Z range to generate
serverpath : the path to the directory in which the server runs (takes precedence over the config file setting)
Switches:
-verbose : causes the application to output the server's messages to the console
-v : same as -verbose
-w : Ignore [WARNING] and [SEVERE] messages.
-alt : alternate server launch sequence
-a : same as -alt
-nowait : don't pause for anything
-n : same as -nowait
-i# : override the iteration spawn offset increment (default 380) (example: -i100)
-x# : set the X offset to generate land around (example: -x0 or -x1000 or -x-500)
-z# : set the Z offset to generate land around (example: -z0 or -z1000 or -z-500)
Other options:
java -jar MinecraftLandGenerator.jar -update
Checks for and downloads new versions of MLG online.
java -jar MinecraftLandGenerator.jar -printspawn
java -jar MinecraftLandGenerator.jar -ps
Outputs the current world's spawn point coordinates.
java -jar MinecraftLandGenerator.jar -conf
java -jar MinecraftLandGenerator.jar -conf download
Generates or downloads a MinecraftLandGenerator.conf file.
java -jar MinecraftLandGenerator.jar -readme readme.txt
java -jar MinecraftLandGenerator.jar -readme
Generates a readme file using supplied name or the default _MLG_Readme.txt
java -jar MinecraftLandGenerator.jar -downloadfile http://example.com/file.txt
Downloads whatever file from the internet you give it.
java -jar MinecraftLandGenerator.jar -downloadlist list.txt
list.txt (or any other file) contains a URL on each line which will be downloaded.
java -jar MinecraftLandGenerator.jar -version
java -jar MinecraftLandGenerator.jar -help
java -jar MinecraftLandGenerator.jar /?
Prints this message.
When launched with the -conf switch, this application creates a MinecraftLandGenerator.conf file that contains configuration options.
If this file does not exist or does not contain all required properties, the application will not run.
MinecraftLandGenerator.conf properties:
Java : The command line to use to launch the server
ServerPath : The path to the directory in which the server runs (can be overridden by the serverpath argument)
Done_Text : The output from the server that tells us that we are done
Preparing_Text : The output from the server that tells us the percentage
Preparing_Level : The output from the server that tells us the level it is working on
Level-0 : Name of Level 0: The Overworld
Level-1 : Name of Level 1: The Nether
Level-2 : Name of Level 2: The End
Level-3 : Name of Level 3: (Future Level)
Level-4 : Name of Level 4: (Future Level)
Level-5 : Name of Level 5: (Future Level)
Level-6 : Name of Level 6: (Future Level)
Level-7 : Name of Level 7: (Future Level)
Level-8 : Name of Level 8: (Future Level)
Level-9 : Name of Level 9: (Future Level)
WaitSave : Optional: Wait before saving.

View File

@ -55,3 +55,4 @@ F96F4F3862138D498B203C2848086289=1338535367000# MLG v1.6.3
F00F81A5C5833DBFF95E85EFD1B8460B=1338951984000# MLG v1.6.3 F00F81A5C5833DBFF95E85EFD1B8460B=1338951984000# MLG v1.6.3
A28CD4B9DE8E3CB25AB56368A4C44A51=1339493851000# MLG v1.6.3 A28CD4B9DE8E3CB25AB56368A4C44A51=1339493851000# MLG v1.6.3
15241C4B45D9711F4AA4EF25004FEDA6=1339559312000# MLG v1.6.3 15241C4B45D9711F4AA4EF25004FEDA6=1339559312000# MLG v1.6.3
21ECF491552F4A706B7874A1C0A31534=1344593776000# MLG v1.7.0

View File

@ -1,6 +1,6 @@
#Minecraft Land Generator Configuration File: Version: 1.6.3 #Minecraft Land Generator Configuration File: Version: 1.7.0
#Authors: Corrodias, Morlok8k, pr0f1x #Authors: Corrodias, Morlok8k, pr0f1x
#Auto-Generated: Tuesday, June 12, 2012 at 8:48 PM Pacific Daylight Time #Auto-Generated: Friday, August 10, 2012 at 3:16 AM Pacific Daylight Time
#Line to run server: #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 Java=java -Djava.awt.headless=true -Djline.terminal=jline.UnsupportedTerminal -Duser.language=en -Xms1024m -Xmx1024m -Xincgc -jar minecraft_server.jar nogui
@ -25,3 +25,4 @@ Level-9=Level 9 (Future Level)
#Optional: Wait a few seconds after saving. #Optional: Wait a few seconds after saving.
WaitSave=false WaitSave=false
webLaunch=true

Binary file not shown.

View File

@ -1,26 +1,26 @@
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files.txt https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files.txt
###RECHECK### ###RECHECK###
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_%28Linux%29.txt https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_Linux.txt
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_%28Mac%29.txt https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_Mac.txt
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_%28Windows%29.txt https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_Windows.txt
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_Windows.cmd

View File

@ -1,10 +1,10 @@
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_%28Linux%29.txt https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_Linux.txt
###RECHECK### ###RECHECK###
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files.txt https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files.txt
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_Linux.sh
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_%28Linux%29.sh https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_Linux.sh

View File

@ -1,10 +1,10 @@
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_%28Mac%29.txt https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_Mac.txt
###RECHECK### ###RECHECK###
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files.txt https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files.txt
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_Mac.command
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_%28Mac%29.command https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_Mac.command

View File

@ -1,10 +1,10 @@
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_%28Windows%29.txt https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files_Windows.txt
###RECHECK### ###RECHECK###
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files.txt https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Update_Files.txt
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_MLG_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Run_Server_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_Server_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/Update_MLG_Extra_Files_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Printspawn_Windows.cmd
https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_%28Windows%29.cmd https://raw.github.com/Morlok8k/MinecraftLandGenerator/master/scripts/MLG_Initial_Setup_Windows.cmd

View File

@ -1,20 +1,19 @@
/** /**
* *
*/ */
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.util.ArrayList; import java.util.ArrayList;
import corrodias.minecraft.landgenerator.Main;
/** /**
* @author morlok8k * @author morlok8k
* *
*/ */
public class MLG_ArrayList { public class Arraylist {
public static ArrayList<Coordinates> arrayListRemove(ArrayList<Coordinates> list, public static ArrayList<Coordinates> arrayListRemove(final ArrayList<Coordinates> list,
ArrayList<Coordinates> remove) { final ArrayList<Coordinates> remove) {
boolean changed = false; boolean changed = false;
changed = list.removeAll(remove); changed = list.removeAll(remove);

View File

@ -1,4 +1,4 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
/** /**
* Coordinates are in the form of [X,Y,Z] or (X,Z)<br> * Coordinates are in the form of [X,Y,Z] or (X,Z)<br>
@ -22,7 +22,7 @@ public class Coordinates {
* @param y * @param y
* @param z * @param z
*/ */
public Coordinates(int x, int y, int z) { public Coordinates(final int x, final int y, final int z) {
super(); super();
X = x; X = x;
Y = y; Y = y;
@ -61,7 +61,7 @@ public class Coordinates {
* @param x * @param x
* the x to set * the x to set
*/ */
public void setX(int x) { public void setX(final int x) {
X = x; X = x;
} }
@ -69,7 +69,7 @@ public class Coordinates {
* @param y * @param y
* the y to set * the y to set
*/ */
public void setY(int y) { public void setY(final int y) {
Y = y; Y = y;
} }
@ -77,7 +77,7 @@ public class Coordinates {
* @param z * @param z
* the z to set * the z to set
*/ */
public void setZ(int z) { public void setZ(final int z) {
Z = z; Z = z;
} }
@ -143,7 +143,7 @@ public class Coordinates {
x = Integer.parseInt(sX); x = Integer.parseInt(sX);
y = Integer.parseInt(sY); y = Integer.parseInt(sY);
z = Integer.parseInt(sZ); z = Integer.parseInt(sZ);
} catch (NumberFormatException e) { } catch (final NumberFormatException e) {
return new Coordinates(0, 0, 0); return new Coordinates(0, 0, 0);
} }
@ -169,7 +169,7 @@ public class Coordinates {
} }
public String toString(boolean Short) { public String toString(final boolean Short) {
if (Short) { // We are overloading toString with an additional option: 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 ("(" + X + "," + Z + ")"); // Basically just an option to return just X and Z (formatted differently as well: "(X,Z)")
} }
@ -188,9 +188,9 @@ public class Coordinates {
final int prime = 31; // My hard coded prime number final int prime = 31; // My hard coded prime number
int result = 1; // The hard coded number I start with int result = 1; // The hard coded number I start with
result = prime * result + X; // Add the X data result = (prime * result) + X; // Add the X data
result = prime * result + Y; // Add the Y data result = (prime * result) + Y; // Add the Y data
result = prime * result + Z; // Add the Z data result = (prime * result) + Z; // Add the Z data
return result; //this result will consistently give the same result for the same 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. // [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. //yes, If I was lazy, I could just do a "return 0;" and it would still be technically valid.
@ -201,27 +201,27 @@ public class Coordinates {
* @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#equals(java.lang.Object)
*/ */
@Override @Override
public boolean equals(Object obj) { public boolean equals(final Object obj) {
// I am overriding the inherited equals method. // I am overriding the inherited equals method.
// Because it doesn't know how to deal with my custom data. // Because it doesn't know how to deal with my custom data.
// So instead of always failing, it actually works! // So instead of always failing, it actually works!
// (by default it gets the memory addresses of each object.) // (by default it gets the memory addresses of each object.)
// An object must equal itself // An object must equal itself
if (this == obj) return true; if (this == obj) { return true; }
// No object equals null // No object equals null
if (obj == null) return false; if (obj == null) { return false; }
if (this == null) return false; if (this == null) { return false; }
// Objects of different types are never equal // Objects of different types are never equal
if (getClass() != obj.getClass()) return false; if (getClass() != obj.getClass()) { return false; }
// Cast to an Coordinates, then compare the data // Cast to an Coordinates, then compare the data
Coordinates c = (Coordinates) obj; final Coordinates c = (Coordinates) obj;
if (X != c.X) return false; if (X != c.X) { return false; }
if (Y != c.Y) return false; if (Y != c.Y) { return false; }
if (Z != c.Z) return false; if (Z != c.Z) { return false; }
return true; // If none of the above returned something, they must be equal! return true; // If none of the above returned something, they must be equal!
} }
} }

View File

@ -1,4 +1,4 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
@ -10,9 +10,8 @@ import java.net.URL;
import org.w3c.bert_bos.UTF8URL.Unescape; import org.w3c.bert_bos.UTF8URL.Unescape;
import corrodias.minecraft.landgenerator.Main;
public class MLG_DownloadFile { public class DownloadFile {
/** /**
* *
@ -29,7 +28,7 @@ public class MLG_DownloadFile {
* Displays output if true * Displays output if true
* @return Boolean: true if download was successful, false if download wasn't * @return Boolean: true if download was successful, false if download wasn't
*/ */
public static boolean downloadFile(String URL, boolean Output) { public static boolean downloadFile(final String URL, final boolean Output) {
boolean success = true; boolean success = true;
@ -41,7 +40,7 @@ public class MLG_DownloadFile {
} }
} }
int size = 1024 * 4; // 1024 * n should be tested to get the optimum size (for download speed.) final int size = 1024 * 4; // 1024 * n should be tested to get the optimum size (for download speed.)
if (fileName.equals("")) { if (fileName.equals("")) {
fileName = String.valueOf(System.currentTimeMillis()); fileName = String.valueOf(System.currentTimeMillis());
@ -54,8 +53,8 @@ public class MLG_DownloadFile {
Main.out("Saving as: " + fileName); Main.out("Saving as: " + fileName);
} }
long differenceTime = System.currentTimeMillis(); final long differenceTime = System.currentTimeMillis();
Long[] timeTracking = new Long[] { differenceTime, differenceTime }; final Long[] timeTracking = new Long[] { differenceTime, differenceTime };
timeTracking[0] = System.currentTimeMillis(); timeTracking[0] = System.currentTimeMillis();
if (Output) { if (Output) {
@ -67,8 +66,8 @@ public class MLG_DownloadFile {
in = new BufferedInputStream(new URL(URL).openStream()); in = new BufferedInputStream(new URL(URL).openStream());
FileOutputStream fos; FileOutputStream fos;
fos = new FileOutputStream(fileName); fos = new FileOutputStream(fileName);
BufferedOutputStream bout = new BufferedOutputStream(fos, size); final BufferedOutputStream bout = new BufferedOutputStream(fos, size);
byte[] data = new byte[size]; final byte[] data = new byte[size];
int x = 0; int x = 0;
int count = 0; int count = 0;
while ((x = in.read(data, 0, size)) >= 0) { while ((x = in.read(data, 0, size)) >= 0) {
@ -88,15 +87,15 @@ public class MLG_DownloadFile {
timeTracking[1] = System.currentTimeMillis(); timeTracking[1] = System.currentTimeMillis();
//differenceTime = (timeTracking[1] - timeTracking[0]); //differenceTime = (timeTracking[1] - timeTracking[0]);
if (Output) { if (Output) {
Main.out("Elapsed Time: " + MLG_Time.displayTime(timeTracking[0], timeTracking[1])); Main.out("Elapsed Time: " + Time.displayTime(timeTracking[0], timeTracking[1]));
} }
} catch (FileNotFoundException e) { } catch (final FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
success = false; success = false;
} catch (MalformedURLException e) { } catch (final MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
success = false; success = false;
} catch (IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
success = false; success = false;
} }

View File

@ -1,4 +1,4 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@ -7,16 +7,15 @@ import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import corrodias.minecraft.landgenerator.Main;
public class MLG_FileRead { public class FileRead {
public static ArrayList<Coordinates> readArrayListCoordLog(String file) { public static ArrayList<Coordinates> readArrayListCoordLog(final String file) {
ArrayList<Coordinates> Return = new ArrayList<Coordinates>(); final ArrayList<Coordinates> Return = new ArrayList<Coordinates>();
try { try {
BufferedReader in = new BufferedReader(new FileReader(new File(file))); final BufferedReader in = new BufferedReader(new FileReader(new File(file)));
String line = ""; String line = "";
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
@ -55,10 +54,10 @@ public class MLG_FileRead {
} }
in.close(); in.close();
} catch (FileNotFoundException ex) { } catch (final FileNotFoundException ex) {
Main.out("Could not find " + file + "."); Main.out("Could not find " + file + ".");
return Return; return Return;
} catch (IOException ex) { } catch (final IOException ex) {
Main.err("Could not read " + file + "."); Main.err("Could not read " + file + ".");
return Return; return Return;
} }
@ -74,8 +73,8 @@ public class MLG_FileRead {
//String errorMsg = ""; //String errorMsg = "";
try { try {
File config = new File(Main.MinecraftLandGeneratorConf); final File config = new File(Main.MinecraftLandGeneratorConf);
BufferedReader in = new BufferedReader(new FileReader(config)); final BufferedReader in = new BufferedReader(new FileReader(config));
String line = ""; String line = "";
String property = ""; String property = "";
String value = ""; String value = "";
@ -175,12 +174,12 @@ public class MLG_FileRead {
Main.outD(" waitSave: " + Main.waitSave); Main.outD(" waitSave: " + Main.waitSave);
Main.outD(" webLaunch: " + Main.webLaunch); Main.outD(" webLaunch: " + Main.webLaunch);
} }
} catch (FileNotFoundException ex) { } catch (final FileNotFoundException ex) {
Main.out("Could not find " Main.out("Could not find "
+ Main.MinecraftLandGeneratorConf + Main.MinecraftLandGeneratorConf
+ ". It is recommended that you run the application with the -conf option to create it."); + ". It is recommended that you run the application with the -conf option to create it.");
return; return;
} catch (IOException ex) { } catch (final IOException ex) {
Main.err("Could not read " + Main.MinecraftLandGeneratorConf + "."); Main.err("Could not read " + Main.MinecraftLandGeneratorConf + ".");
return; return;
} }

View File

@ -1,17 +1,16 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import corrodias.minecraft.landgenerator.Main;
/** /**
* http://www.roseindia.net/java/example/java/io/java-append-to-file.shtml <br> * http://www.roseindia.net/java/example/java/io/java-append-to-file.shtml <br>
* Append To File - Java Tutorial * Append To File - Java Tutorial
*/ */
public class MLG_FileWrite { public class FileWrite {
public static final String newLine = Main.newLine; public static final String newLine = Main.newLine;
@ -19,16 +18,16 @@ public class MLG_FileWrite {
* @param file * @param file
* @param appendTxt * @param appendTxt
*/ */
public static void AppendTxtFile(String file, String appendTxt) { public static void AppendTxtFile(final String file, final String appendTxt) {
try { try {
// Create file // Create file
FileWriter fstream = new FileWriter(file, true); final FileWriter fstream = new FileWriter(file, true);
BufferedWriter out = new BufferedWriter(fstream); final BufferedWriter out = new BufferedWriter(fstream);
//String output = "Hello Java" + newLine; //String output = "Hello Java" + newLine;
out.write(appendTxt); out.write(appendTxt);
//Close the output stream //Close the output stream
out.close(); out.close();
} catch (Exception e) {//Catch exception if any } catch (final Exception e) {//Catch exception if any
System.err.println("Error: " + e.getMessage()); System.err.println("Error: " + e.getMessage());
} }
} }
@ -37,7 +36,7 @@ public class MLG_FileWrite {
* @param file * @param file
* @param txt * @param txt
*/ */
public static void writeTxtFile(String file, String txt) { public static void writeTxtFile(final String file, final String txt) {
//TODO: element comment //TODO: element comment
/* /*
@ -47,14 +46,14 @@ public class MLG_FileWrite {
*/ */
try { try {
File oFile = new File(file); final File oFile = new File(file);
BufferedWriter outFile = new BufferedWriter(new FileWriter(oFile)); final BufferedWriter outFile = new BufferedWriter(new FileWriter(oFile));
outFile.write(txt); outFile.write(txt);
outFile.newLine(); outFile.newLine();
outFile.close(); outFile.close();
Main.out(file + " file created."); Main.out(file + " file created.");
return; return;
} catch (IOException ex) { } catch (final IOException ex) {
Main.err("Could not create " + Main.MinecraftLandGeneratorConf + "."); Main.err("Could not create " + Main.MinecraftLandGeneratorConf + ".");
ex.printStackTrace(); ex.printStackTrace();
return; return;
@ -69,7 +68,7 @@ public class MLG_FileWrite {
* true: Uses Default values. false: uses existing values * true: Uses Default values. false: uses existing values
* @author Morlok8k * @author Morlok8k
*/ */
public static void saveConf(boolean newConf) { public static void saveConf(final boolean newConf) {
String jL = null; //javaLine String jL = null; //javaLine
String sP = null; //serverPath String sP = null; //serverPath

View File

@ -1,8 +1,7 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import corrodias.minecraft.landgenerator.Main;
public class MLG_input_CLI { public class Input_CLI {
/** /**
* getInt(String msg) - outputs a message, will only accept a valid integer from keyboard * getInt(String msg) - outputs a message, will only accept a valid integer from keyboard
@ -12,7 +11,7 @@ public class MLG_input_CLI {
* @return int * @return int
* @author Morlok8k * @author Morlok8k
*/ */
public static int getInt(String msg) { public static int getInt(final String msg) {
int Return = 0; int Return = 0;

View File

@ -1,4 +1,4 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -9,7 +9,7 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Locale; import java.util.Locale;
public class MLG_MD5 { public class MD5 {
/** /**
* This gets the MD5 of a file <br> * This gets the MD5 of a file <br>
@ -19,29 +19,29 @@ public class MLG_MD5 {
* *
* @author Morlok8k * @author Morlok8k
*/ */
public static String fileMD5(String fileName) throws NoSuchAlgorithmException, public static String fileMD5(final String fileName) throws NoSuchAlgorithmException,
FileNotFoundException { FileNotFoundException {
// out(""); // out("");
// out(""); // out("");
MessageDigest digest = MessageDigest.getInstance("MD5"); final MessageDigest digest = MessageDigest.getInstance("MD5");
InputStream is = new FileInputStream(fileName); final InputStream is = new FileInputStream(fileName);
byte[] buffer = new byte[8192]; final byte[] buffer = new byte[8192];
int read = 0; int read = 0;
try { try {
while ((read = is.read(buffer)) > 0) { while ((read = is.read(buffer)) > 0) {
digest.update(buffer, 0, read); digest.update(buffer, 0, read);
} }
byte[] md5sum = digest.digest(); final byte[] md5sum = digest.digest();
BigInteger bigInt = new BigInteger(1, md5sum); final BigInteger bigInt = new BigInteger(1, md5sum);
String output = String.format("%1$032X", bigInt); //pad on left to 32 chars with 0's, also capitalize. final String output = String.format("%1$032X", bigInt); //pad on left to 32 chars with 0's, also capitalize.
// out("MD5: " + output); // out("MD5: " + output);
return output.toUpperCase(Locale.ENGLISH); return output.toUpperCase(Locale.ENGLISH);
} catch (IOException e) { } catch (final IOException e) {
throw new RuntimeException("Unable to process file for MD5", e); throw new RuntimeException("Unable to process file for MD5", e);
} finally { } finally {
try { try {
is.close(); is.close();
} catch (IOException e) { } catch (final IOException e) {
throw new RuntimeException("Unable to close input stream for MD5 calculation", e); throw new RuntimeException("Unable to close input stream for MD5 calculation", e);
} }
} }

View File

@ -1,4 +1,4 @@
package corrodias.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@ -17,19 +17,6 @@ import java.util.Scanner;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import morlok8k.minecraft.landgenerator.Coordinates;
import morlok8k.minecraft.landgenerator.MLG_ArrayList;
import morlok8k.minecraft.landgenerator.MLG_DownloadFile;
import morlok8k.minecraft.landgenerator.MLG_FileRead;
import morlok8k.minecraft.landgenerator.MLG_FileWrite;
import morlok8k.minecraft.landgenerator.MLG_MD5;
import morlok8k.minecraft.landgenerator.MLG_Readme_and_HelpInfo;
import morlok8k.minecraft.landgenerator.MLG_SelfAware;
import morlok8k.minecraft.landgenerator.MLG_StringArrayParse;
import morlok8k.minecraft.landgenerator.MLG_Time;
import morlok8k.minecraft.landgenerator.MLG_Update;
import morlok8k.minecraft.landgenerator.MLG_input_CLI;
/** /**
* *
* @author Corrodias, Morlok8k, pr0f1x * @author Corrodias, Morlok8k, pr0f1x
@ -37,13 +24,13 @@ import morlok8k.minecraft.landgenerator.MLG_input_CLI;
*/ */
public class Main { public class Main {
//java.awt.Desktop.getDesktop().browse(splashPage); //
// //
// Public Vars: // Public Vars:
public static boolean testing = false; // display more output when debugging public static boolean testing = false; // display more output when debugging
public static final String PROG_NAME = "Minecraft Land Generator"; // Program Name public static final String PROG_NAME = "Minecraft Land Generator"; // Program Name
public static final String VERSION = "1.7.0 test7"; // Version Number! public static final String VERSION = "1.7.0"; // Version Number!
public static final String AUTHORS = "Corrodias, Morlok8k, pr0f1x"; // Authors public static final String AUTHORS = "Corrodias, Morlok8k, pr0f1x"; // Authors
public static final String fileSeparator = System.getProperty("file.separator"); public static final String fileSeparator = System.getProperty("file.separator");
@ -188,7 +175,7 @@ public class Main {
String[] argsNOGUI = new String[args.length]; String[] argsNOGUI = new String[args.length];
argsNOGUI = args; argsNOGUI = args;
argsNOGUI = MLG_StringArrayParse.Parse(argsNOGUI, "nogui"); //parse out "nogui" argsNOGUI = StringArrayParse.Parse(argsNOGUI, "nogui"); //parse out "nogui"
if (!(args.equals(argsNOGUI))) { //do the freshly parsed args match the original? if (!(args.equals(argsNOGUI))) { //do the freshly parsed args match the original?
args = argsNOGUI; //use the freshly parsed args for everything else now... args = argsNOGUI; //use the freshly parsed args for everything else now...
NOGUI = true; NOGUI = true;
@ -241,7 +228,7 @@ public class Main {
// Lets get the date, and our BuildID // Lets get the date, and our BuildID
date = new Date(); date = new Date();
MLG_Update.readBuildID(); Update.readBuildID();
// 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.
@ -262,8 +249,8 @@ public class Main {
// (-nowait is the only universal switch - it can be used with anything. its basically for scripting, as it turns off the 10sec wait for human readability) // (-nowait is the only universal switch - it can be used with anything. its basically for scripting, as it turns off the 10sec wait for human readability)
String[] newArgs = new String[args.length]; String[] newArgs = new String[args.length];
newArgs = args; newArgs = args;
newArgs = MLG_StringArrayParse.Parse(newArgs, "-n"); //parse out -n newArgs = StringArrayParse.Parse(newArgs, "-n"); //parse out -n
newArgs = MLG_StringArrayParse.Parse(newArgs, "-nowait"); //parse out -nowait newArgs = StringArrayParse.Parse(newArgs, "-nowait"); //parse out -nowait
if (!(args.equals(newArgs))) { //do the freshly parsed args match the original? if (!(args.equals(newArgs))) { //do the freshly parsed args match the original?
dontWait = true; //if not, we dont wait for anything! dontWait = true; //if not, we dont wait for anything!
args = newArgs; //use the freshly parsed args for everything else now... args = newArgs; //use the freshly parsed args for everything else now...
@ -273,9 +260,9 @@ public class Main {
if (args.length == 0) { //we didnt find a an X and Z size, so lets ask for one. if (args.length == 0) { //we didnt find a an X and Z size, so lets ask for one.
out("Please Enter the size of world you want. Example: X:1000 Z:1000"); out("Please Enter the size of world you want. Example: X:1000 Z:1000");
outP(MLG + "X:"); outP(MLG + "X:");
xRange = MLG_input_CLI.getInt("X:"); xRange = Input_CLI.getInt("X:");
outP(MLG + "Z:"); outP(MLG + "Z:");
zRange = MLG_input_CLI.getInt("Z:"); zRange = Input_CLI.getInt("Z:");
args = new String[] { String.valueOf(xRange), String.valueOf(zRange) }; args = new String[] { String.valueOf(xRange), String.valueOf(zRange) };
} }
@ -283,7 +270,7 @@ public class Main {
if (args[0].equalsIgnoreCase("-version") || args[0].equalsIgnoreCase("-help") if (args[0].equalsIgnoreCase("-version") || args[0].equalsIgnoreCase("-help")
|| args[0].equals("/?")) { || args[0].equals("/?")) {
MLG_Readme_and_HelpInfo.showHelp(true); Readme_and_HelpInfo.showHelp(true);
return; return;
} }
@ -297,8 +284,8 @@ public class Main {
if (args.length == 2) { if (args.length == 2) {
if (args[1].equalsIgnoreCase("download")) { if (args[1].equalsIgnoreCase("download")) {
boolean fileSuccess = final boolean fileSuccess =
MLG_DownloadFile.downloadFile(github_MLG_Conf_URL, testing); DownloadFile.downloadFile(github_MLG_Conf_URL, testing);
if (fileSuccess) { if (fileSuccess) {
out(MinecraftLandGeneratorConf + " file downloaded."); out(MinecraftLandGeneratorConf + " file downloaded.");
return; return;
@ -306,35 +293,35 @@ public class Main {
} }
} }
MLG_FileWrite.saveConf(true); //new conf file FileWrite.saveConf(true); //new conf file
return; return;
} else if (args[0].equalsIgnoreCase("-ps") || args[0].equalsIgnoreCase("-printspawn")) { } else if (args[0].equalsIgnoreCase("-ps") || args[0].equalsIgnoreCase("-printspawn")) {
// okay, sorry, this is an ugly hack, but it's just a last-minute feature. // okay, sorry, this is an ugly hack, but it's just a last-minute feature.
MLG_Misc.printSpawn(); Misc.printSpawn();
MLG_Time.waitTenSec(false); Time.waitTenSec(false);
return; return;
} else if (args[0].equalsIgnoreCase("-build")) { } else if (args[0].equalsIgnoreCase("-build")) {
MLG_Update.buildID(false); Update.buildID(false);
return; return;
} else if (args[0].equalsIgnoreCase("-update")) { } else if (args[0].equalsIgnoreCase("-update")) {
MLG_Update.updateMLG(); Update.updateMLG();
MLG_Time.waitTenSec(false); Time.waitTenSec(false);
return; return;
} else if (args[0].equalsIgnoreCase("-readme")) { } else if (args[0].equalsIgnoreCase("-readme")) {
if (args.length == 2) { if (args.length == 2) {
MLG_Readme_and_HelpInfo.readMe(args[1]); Readme_and_HelpInfo.readMe(args[1]);
} else { } else {
MLG_Readme_and_HelpInfo.readMe(null); Readme_and_HelpInfo.readMe(null);
} }
return; return;
} else if (args[0].equalsIgnoreCase("-downloadfile")) { } else if (args[0].equalsIgnoreCase("-downloadfile")) {
if (args.length == 2) { if (args.length == 2) {
MLG_DownloadFile.downloadFile(args[1], true); DownloadFile.downloadFile(args[1], true);
} else { } else {
out("No File to Download!"); out("No File to Download!");
MLG_Time.waitTenSec(false); Time.waitTenSec(false);
} }
return; return;
@ -345,38 +332,39 @@ public class Main {
String recheckMD5 = ""; String recheckMD5 = "";
try { try {
File config = new File(args[1]); final File config = new File(args[1]);
try { try {
origMD5 = MLG_MD5.fileMD5(config.toString()); origMD5 = MD5.fileMD5(config.toString());
} catch (NoSuchAlgorithmException e) { } catch (final NoSuchAlgorithmException e) {
e.printStackTrace(); e.printStackTrace();
} }
BufferedReader in = new BufferedReader(new FileReader(config)); final BufferedReader in = new BufferedReader(new FileReader(config));
String line; String line;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
if (line.contains("###RECHECK###")) { if (line.contains("###RECHECK###")) {
recheckFlag = !recheckFlag; recheckFlag = !recheckFlag;
} else { } else {
MLG_DownloadFile.downloadFile(line, true); DownloadFile.downloadFile(line, true);
} }
} }
in.close(); in.close();
if (recheckFlag == true) { if (recheckFlag == true) {
try { try {
recheckMD5 = MLG_MD5.fileMD5(config.toString()); recheckMD5 = MD5.fileMD5(config.toString());
} catch (NoSuchAlgorithmException e) { } catch (final NoSuchAlgorithmException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (!origMD5.contentEquals(recheckMD5)) { if (!origMD5.contentEquals(recheckMD5)) {
BufferedReader in_recheck = new BufferedReader(new FileReader(config)); final BufferedReader in_recheck =
new BufferedReader(new FileReader(config));
String line_recheck; String line_recheck;
while ((line_recheck = in_recheck.readLine()) != null) { while ((line_recheck = in_recheck.readLine()) != null) {
if (line_recheck.contains("###RECHECK###")) { if (line_recheck.contains("###RECHECK###")) {
recheckFlag = !recheckFlag; recheckFlag = !recheckFlag;
} else { } else {
MLG_DownloadFile.downloadFile(line_recheck, true); DownloadFile.downloadFile(line_recheck, true);
} }
} }
in_recheck.close(); in_recheck.close();
@ -384,32 +372,32 @@ public class Main {
} }
} catch (FileNotFoundException ex) { } catch (final FileNotFoundException ex) {
System.err.println(args[1] + " - File not found"); System.err.println(args[1] + " - File not found");
MLG_Time.waitTenSec(false); Time.waitTenSec(false);
return; return;
} catch (IOException ex) { } catch (final IOException ex) {
System.err.println(args[1] + " - Could not read file."); System.err.println(args[1] + " - Could not read file.");
MLG_Time.waitTenSec(false); Time.waitTenSec(false);
return; return;
} }
} else { } else {
out("No File with links!"); out("No File with links!");
MLG_Time.waitTenSec(false); Time.waitTenSec(false);
} }
return; return;
} else if (args.length == 1) { } else if (args.length == 1) {
out("For help, use java -jar " + MLGFileNameShort + " -help"); out("For help, use java -jar " + MLGFileNameShort + " -help");
MLG_Time.waitTenSec(false); Time.waitTenSec(false);
return; return;
} }
MLG_FileRead.readConf(); FileRead.readConf();
boolean oldConf = false; // This next section checks to see if we have a old configuration file (or none!) boolean oldConf = false; // This next section checks to see if we have a old configuration file (or none!)
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.
err(MinecraftLandGeneratorConf err(MinecraftLandGeneratorConf
+ " does not contain all required properties. Making New File!"); // Please recreate it by running this application with -conf. + " does not contain all required properties. Making New File!"); // Please recreate it by running this application with -conf.
@ -437,9 +425,9 @@ public class Main {
if (oldConf) { if (oldConf) {
err("Old Version of " + MinecraftLandGeneratorConf + " found. Updating..."); err("Old Version of " + MinecraftLandGeneratorConf + " found. Updating...");
MLG_FileWrite.saveConf(false); //old conf FileWrite.saveConf(false); //old conf
MLG_Time.waitTenSec(false); Time.waitTenSec(false);
return; return;
} }
@ -458,11 +446,11 @@ public class Main {
err("Z size too small - Changing Z to 1000"); err("Z size too small - Changing Z to 1000");
} }
} catch (NumberFormatException ex) { } catch (final NumberFormatException ex) {
err("Invalid X or Z argument."); err("Invalid X or Z argument.");
err("Please Enter the size of world you want. Example: X:1000 Z:1000"); err("Please Enter the size of world you want. Example: X:1000 Z:1000");
xRange = MLG_input_CLI.getInt("X:"); xRange = Input_CLI.getInt("X:");
zRange = MLG_input_CLI.getInt("Z:"); zRange = Input_CLI.getInt("Z:");
//return; //return;
} }
@ -472,8 +460,8 @@ public class Main {
// This is embarrassing. Don't look. // This is embarrassing. Don't look.
try { try {
for (int i = 0; i < args.length - 2; i++) { for (int i = 0; i < (args.length - 2); i++) {
String nextSwitch = args[i + 2].toLowerCase(); final String nextSwitch = args[i + 2].toLowerCase();
if (nextSwitch.equals("-verbose") || nextSwitch.equals("-v")) { if (nextSwitch.equals("-verbose") || nextSwitch.equals("-v")) {
verbose = true; verbose = true;
out("Notice: Verbose Mode"); out("Notice: Verbose Mode");
@ -508,7 +496,7 @@ public class Main {
out("Notice: Z Offset: " + zOffset); out("Notice: Z Offset: " + zOffset);
if (nextSwitch.startsWith("-y")) { if (nextSwitch.startsWith("-y")) {
out("Notice: MLG now uses Z instead of Y. Please use the -z switch instead"); out("Notice: MLG now uses Z instead of Y. Please use the -z switch instead");
MLG_Time.waitTenSec(false); Time.waitTenSec(false);
} }
} else { } else {
@ -516,36 +504,36 @@ public class Main {
out("Notice: Attempting to use Alternate Server:" + serverPath); out("Notice: Attempting to use Alternate Server:" + serverPath);
} }
} }
} catch (NumberFormatException ex) { } catch (final NumberFormatException ex) {
err("Invalid switch value."); err("Invalid switch value.");
return; return;
} }
MLG_WorldVerify.verifyWorld(); WorldVerify.verifyWorld();
{ {
File backupLevel = new File(worldPath + fileSeparator + "level_backup.dat"); final File backupLevel = new File(worldPath + fileSeparator + "level_backup.dat");
if (backupLevel.exists()) { if (backupLevel.exists()) {
//err("There is a level_backup.dat file left over from a previous attempt that failed. You should go determine whether to keep the current level.dat" //err("There is a level_backup.dat file left over from a previous attempt that failed. You should go determine whether to keep the current level.dat"
// + " or restore the backup."); // + " or restore the backup.");
//err("You most likely will want to restore the backup!"); //err("You most likely will want to restore the backup!");
//MLG_Time.waitTenSec(false); //Time.waitTenSec(false);
err("There is a level_backup.dat file left over from a previous attempt that failed."); err("There is a level_backup.dat file left over from a previous attempt that failed.");
out("Resuming..."); out("Resuming...");
//use resume data //use resume data
File serverLevel = new File(worldPath + fileSeparator + "level.dat"); final File serverLevel = new File(worldPath + fileSeparator + "level.dat");
try { try {
MLG_Misc.copyFile(backupLevel, serverLevel); Misc.copyFile(backupLevel, serverLevel);
} catch (IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
backupLevel.delete(); backupLevel.delete();
//return; //return;
MLG_FileRead.readArrayListCoordLog(worldPath + fileSeparator FileRead.readArrayListCoordLog(worldPath + fileSeparator
+ "MinecraftLandGenerator.log"); // we read the .log just for any resume data, if any. + "MinecraftLandGenerator.log"); // we read the .log just for any resume data, if any.
System.gc(); //run the garbage collector - hopefully free up some memory! System.gc(); //run the garbage collector - hopefully free up some memory!
@ -575,9 +563,9 @@ public class Main {
try { try {
out("Launching server once to make sure there is a world."); out("Launching server once to make sure there is a world.");
long generationStartTimeTracking = System.currentTimeMillis(); //Start of time remaining calculations. final long generationStartTimeTracking = System.currentTimeMillis(); //Start of time remaining calculations.
boolean serverLaunch = MLG_Server.runMinecraft(alternate); final boolean serverLaunch = Server.runMinecraft(alternate);
if (!(serverLaunch)) { if (!(serverLaunch)) {
System.exit(1); // we got a warning or severe error System.exit(1); // we got a warning or severe error
@ -590,26 +578,26 @@ public class Main {
xRange = (int) (Math.ceil(((double) xRange) / ((double) 16))) * 16; //say xRange was entered as 1000. this changes it to be 1008, a multiple of 16. (the size of a chunk) xRange = (int) (Math.ceil(((double) xRange) / ((double) 16))) * 16; //say xRange was entered as 1000. this changes it to be 1008, a multiple of 16. (the size of a chunk)
zRange = (int) (Math.ceil(((double) zRange) / ((double) 16))) * 16; //say zRange was entered as 2000. there is no change, as it already is a multiple of 16. zRange = (int) (Math.ceil(((double) zRange) / ((double) 16))) * 16; //say zRange was entered as 2000. there is no change, as it already is a multiple of 16.
MLG_FileWrite.AppendTxtFile( FileWrite.AppendTxtFile(
worldPath + fileSeparator + "MinecraftLandGenerator.log", worldPath + fileSeparator + "MinecraftLandGenerator.log",
"# " + PROG_NAME + " " + VERSION + " - " + MLG_SelfAware.JVMinfo() + newLine "# " + PROG_NAME + " " + VERSION + " - " + SelfAware.JVMinfo() + newLine + "# "
+ "# " + MC_Server_Version + newLine + "# Started: " + MC_Server_Version + newLine + "# Started: "
+ dateFormat.format(generationStartTimeTracking) + newLine + dateFormat.format(generationStartTimeTracking) + newLine
+ "##Size: X" + xRange + "Z" + zRange + newLine); + "##Size: X" + xRange + "Z" + zRange + newLine);
out(""); out("");
File serverLevel = new File(worldPath + fileSeparator + "level.dat"); final File serverLevel = new File(worldPath + fileSeparator + "level.dat");
File backupLevel = new File(worldPath + fileSeparator + "level_backup.dat"); final File backupLevel = new File(worldPath + fileSeparator + "level_backup.dat");
out("Backing up level.dat to level_backup.dat."); out("Backing up level.dat to level_backup.dat.");
MLG_Misc.copyFile(serverLevel, backupLevel); Misc.copyFile(serverLevel, backupLevel);
out(""); out("");
Coordinates spawn = MLG_SpawnPoint.getSpawn(serverLevel); final Coordinates spawn = SpawnPoint.getSpawn(serverLevel);
out("Spawn point detected: [X,Y,Z] " + spawn); out("Spawn point detected: [X,Y,Z] " + spawn);
MLG_FileWrite.AppendTxtFile(worldPath + fileSeparator + "MinecraftLandGenerator.log", FileWrite.AppendTxtFile(worldPath + fileSeparator + "MinecraftLandGenerator.log",
"# Seed: " + randomSeed + newLine + "# Spawn: " + spawn.toString() + newLine); "# Seed: " + randomSeed + newLine + "# Spawn: " + spawn.toString() + newLine);
{ {
@ -663,7 +651,7 @@ public class Main {
Long timeTracking = 0L; Long timeTracking = 0L;
ArrayList<Coordinates> launchList = new ArrayList<Coordinates>(totalIterations); final ArrayList<Coordinates> launchList = new ArrayList<Coordinates>(totalIterations);
for (int currentX = 0; currentX <= (xRangeAdj / 2); currentX += increment) { for (int currentX = 0; currentX <= (xRangeAdj / 2); currentX += increment) {
curXloops++; curXloops++;
@ -685,7 +673,7 @@ public class Main {
{ {
// add Coordinates to arraylist here // add Coordinates to arraylist here
Coordinates tempCoords = final Coordinates tempCoords =
new Coordinates(currentX + xOffset, 64, currentZ + zOffset); new Coordinates(currentX + xOffset, 64, currentZ + zOffset);
launchList.add(tempCoords); launchList.add(tempCoords);
@ -706,12 +694,12 @@ public class Main {
} }
//get existing list, and remove this list from launchList //get existing list, and remove this list from launchList
ArrayList<Coordinates> removeList = final ArrayList<Coordinates> removeList =
MLG_FileRead.readArrayListCoordLog(worldPath + fileSeparator FileRead.readArrayListCoordLog(worldPath + fileSeparator
+ "MinecraftLandGenerator.log"); + "MinecraftLandGenerator.log");
if (!(removeList.isEmpty())) { if (!(removeList.isEmpty())) {
MLG_ArrayList.arrayListRemove(launchList, removeList); Arraylist.arrayListRemove(launchList, removeList);
} }
removeList.clear(); // we are done with this now. removeList.clear(); // we are done with this now.
@ -721,7 +709,7 @@ public class Main {
currentIteration = 0; currentIteration = 0;
totalIterations = launchList.size(); totalIterations = launchList.size();
Coordinates xyz = null; Coordinates xyz = null;
Iterator<Coordinates> coordArrayIterator = launchList.iterator(); final Iterator<Coordinates> coordArrayIterator = launchList.iterator();
while (coordArrayIterator.hasNext()) { while (coordArrayIterator.hasNext()) {
currentIteration++; currentIteration++;
xyz = coordArrayIterator.next(); xyz = coordArrayIterator.next();
@ -730,7 +718,7 @@ public class Main {
String percentDone = String percentDone =
Double.toString(((double) currentIteration / (double) totalIterations) * 100); Double.toString(((double) currentIteration / (double) totalIterations) * 100);
int percentIndex = final int percentIndex =
((percentDone.indexOf(".") + 3) > percentDone.length()) ? percentDone ((percentDone.indexOf(".") + 3) > percentDone.length()) ? percentDone
.length() : (percentDone.indexOf(".") + 3); //fix index on numbers like 12.3 .length() : (percentDone.indexOf(".") + 3); //fix index on numbers like 12.3
percentDone = percentDone =
@ -747,22 +735,22 @@ public class Main {
differenceTime = differenceTime =
(timeTracking - generationStartTimeTracking) / (currentIteration + 1); // Updated. we now count all runs, instead of the last 4. (timeTracking - generationStartTimeTracking) / (currentIteration + 1); // Updated. we now count all runs, instead of the last 4.
differenceTime *= 1 + (totalIterations - currentIteration); // this should provide a more accurate result. differenceTime *= 1 + (totalIterations - currentIteration); // this should provide a more accurate result.
out("Estimated time remaining: " + MLG_Time.displayTime(differenceTime)); // I've noticed it gets pretty accurate after about 8 launches! out("Estimated time remaining: " + Time.displayTime(differenceTime)); // I've noticed it gets pretty accurate after about 8 launches!
// Set the spawn point // Set the spawn point
MLG_SpawnPoint.setSpawn(serverLevel, xyz); SpawnPoint.setSpawn(serverLevel, xyz);
// Launch the server // Launch the server
boolean serverSuccess = false; boolean serverSuccess = false;
serverSuccess = MLG_Server.runMinecraft(alternate); serverSuccess = Server.runMinecraft(alternate);
out(""); out("");
//////// End server launch code //////// End server launch code
if (serverSuccess) { if (serverSuccess) {
// Write the current Coordinates to log file! // Write the current Coordinates to log file!
MLG_FileWrite.AppendTxtFile(worldPath + fileSeparator FileWrite.AppendTxtFile(worldPath + fileSeparator
+ "MinecraftLandGenerator.log", xyz.toString() + newLine); + "MinecraftLandGenerator.log", xyz.toString() + newLine);
} else { } else {
System.exit(1); // we got a warning or severe error System.exit(1); // we got a warning or severe error
@ -776,13 +764,13 @@ public class Main {
out("Finished generating chunks."); out("Finished generating chunks.");
} }
MLG_Misc.copyFile(backupLevel, serverLevel); Misc.copyFile(backupLevel, serverLevel);
backupLevel.delete(); backupLevel.delete();
out("Restored original level.dat."); out("Restored original level.dat.");
out("Generation complete in: " out("Generation complete in: "
+ MLG_Time.displayTime(startTime, System.currentTimeMillis())); + Time.displayTime(startTime, System.currentTimeMillis()));
MLG_Time.waitTenSec(false); Time.waitTenSec(false);
//TODO: add if's //TODO: add if's
@ -790,21 +778,21 @@ public class Main {
if (java.awt.GraphicsEnvironment.isHeadless()) { if (java.awt.GraphicsEnvironment.isHeadless()) {
webLaunch = false; //headless enviroment - cant bring up webpage! webLaunch = false; //headless enviroment - cant bring up webpage!
} }
File web1 = new File("web"); final File web1 = new File("web");
File web2 = new File("web.txt"); //user has put in the magical file to not launch the webpage final File web2 = new File("web.txt"); //user has put in the magical file to not launch the webpage
File web3 = new File("web.txt.txt"); final File web3 = new File("web.txt.txt");
if (web2.exists() || (web1.exists() || web3.exists())) { //check for "web.txt", if not found, check for "web", and if still not found, check for "web.txt.txt" if (web2.exists() || (web1.exists() || web3.exists())) { //check for "web.txt", if not found, check for "web", and if still not found, check for "web.txt.txt"
webLaunch = false; webLaunch = false;
} }
} }
if (webLaunch && java.awt.Desktop.isDesktopSupported()) { if (webLaunch && java.awt.Desktop.isDesktopSupported()) {
URI splashPage = final URI splashPage =
//URI.create("https://sites.google.com/site/minecraftlandgenerator/home/mlg_splash"); //URI.create("https://sites.google.com/site/minecraftlandgenerator/home/mlg_splash");
URI.create("http://adf.ly/520855/splashbanner"); URI.create("http://adf.ly/520855/splashbanner");
try { try {
java.awt.Desktop.getDesktop().browse(splashPage); java.awt.Desktop.getDesktop().browse(splashPage);
} catch (IOException e) { } catch (final IOException e) {
err("Error displaying webpage... " + e.getLocalizedMessage()); err("Error displaying webpage... " + e.getLocalizedMessage());
} }
} else { } else {
@ -813,7 +801,7 @@ public class Main {
out("Thanks!"); out("Thanks!");
} }
} catch (IOException ex) { } catch (final IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); Logger.getLogger(Main.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
} }
} }
@ -825,7 +813,7 @@ public class Main {
* String to display and format * String to display and format
* @author Morlok8k * @author Morlok8k
*/ */
public static void out(String str) { public static void out(final String str) {
System.out.println(MLG + str); // is there a better/easier way to do this? I just wanted a lazier way to write "System.out.println(MLG + blah..." System.out.println(MLG + str); // is there a better/easier way to do this? I just wanted a lazier way to write "System.out.println(MLG + blah..."
} }
@ -836,7 +824,7 @@ public class Main {
* String to display and format * String to display and format
* @author Morlok8k * @author Morlok8k
*/ */
public static void err(String str) { public static void err(final String str) {
System.err.println(MLGe + str); System.err.println(MLGe + str);
} }
@ -847,7 +835,7 @@ public class Main {
* String to display and format * String to display and format
* @author Morlok8k * @author Morlok8k
*/ */
public static void outP(String str) { public static void outP(final String str) {
System.out.print(str); System.out.print(str);
} }
@ -858,7 +846,7 @@ public class Main {
* String to display and format * String to display and format
* @author Morlok8k * @author Morlok8k
*/ */
static void outS(String str) { static void outS(final String str) {
System.out.println("[Server] " + str); System.out.println("[Server] " + str);
} }
@ -869,7 +857,7 @@ public class Main {
* String to display and format * String to display and format
* @author Morlok8k * @author Morlok8k
*/ */
public static void outD(String str) { public static void outD(final String str) {
System.out.println(MLG + "[DEBUG] " + str); System.out.println(MLG + "[DEBUG] " + str);
} }

View File

@ -1,4 +1,4 @@
package corrodias.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -7,10 +7,8 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import morlok8k.minecraft.landgenerator.Coordinates;
import morlok8k.minecraft.landgenerator.MLG_FileRead;
public class MLG_Misc { public class Misc {
//TODO: add description //TODO: add description
/** /**
@ -20,15 +18,15 @@ public class MLG_Misc {
// ugh, sorry, this is an ugly hack, but it's a last-minute feature. this is a lot of duplicated code. // ugh, sorry, this is an ugly hack, but it's a last-minute feature. this is a lot of duplicated code.
// - Fixed by Morlok8k // - Fixed by Morlok8k
MLG_FileRead.readConf(); FileRead.readConf();
MLG_WorldVerify.verifyWorld(); WorldVerify.verifyWorld();
File level = new File(Main.worldPath + Main.fileSeparator + "level.dat"); final File level = new File(Main.worldPath + Main.fileSeparator + "level.dat");
try { try {
Coordinates spawn = MLG_SpawnPoint.getSpawn(level); final Coordinates spawn = SpawnPoint.getSpawn(level);
Main.out("The current spawn point is: [X,Y,Z] " + spawn); Main.out("The current spawn point is: [X,Y,Z] " + spawn);
return true; return true;
} catch (IOException ex) { } catch (final IOException ex) {
Main.err("Error while reading " + level.getPath()); Main.err("Error while reading " + level.getPath());
return false; return false;
} }
@ -45,12 +43,12 @@ public class MLG_Misc {
* @param dst * @param dst
* @throws IOException * @throws IOException
*/ */
public static void copyFile(File src, File dst) throws IOException { public static void copyFile(final File src, final File dst) throws IOException {
InputStream copyIn = new FileInputStream(src); final InputStream copyIn = new FileInputStream(src);
OutputStream copyOut = new FileOutputStream(dst); final OutputStream copyOut = new FileOutputStream(dst);
// Transfer bytes from in to out // Transfer bytes from in to out
byte[] buf = new byte[1024]; final byte[] buf = new byte[1024];
int len; int len;
while ((len = copyIn.read(buf)) >= 0) { while ((len = copyIn.read(buf)) >= 0) {
if (len > 0) { if (len > 0) {

View File

@ -1,8 +1,7 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import corrodias.minecraft.landgenerator.Main;
public class MLG_RCON { public class RCON {
/** /**
* connects to server using RCON, sends a message, and disconnects. Not Functional yet. * connects to server using RCON, sends a message, and disconnects. Not Functional yet.
@ -10,7 +9,7 @@ public class MLG_RCON {
* @param message * @param message
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static void rconConnectAndSendMsg(String message) { private static void rconConnectAndSendMsg(final String message) {
//This is a placeholder for future code. //This is a placeholder for future code.
/* /*
step 1: connect to rcon_IPaddress : rcon_Port, with rcon_Password. step 1: connect to rcon_IPaddress : rcon_Port, with rcon_Password.
@ -30,7 +29,7 @@ public class MLG_RCON {
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static boolean rconQueryServer() { private static boolean rconQueryServer() {
boolean QuerySucess = false; final boolean QuerySucess = false;
//This is a placeholder for future code. //This is a placeholder for future code.
/* /*

View File

@ -0,0 +1,316 @@
package morlok8k.MinecraftLandGenerator;
public class Readme_and_HelpInfo {
static String newLine = Main.newLine;
static String MLGFileNameShort = Main.MLGFileNameShort;
static String MinecraftLandGeneratorConf = Main.MinecraftLandGeneratorConf;
static String defaultReadmeFile = Main.defaultReadmeFile;
/**
* Saves a Readme file.
*
* @param readmeFile
* @author Morlok8k
*
*/
public static void readMe(String readmeFile) {
if ((readmeFile == "") || (readmeFile == null)) {
readmeFile = defaultReadmeFile;
}
final String MLG_Last_Modified_MDY =
Main.dateFormat_MDY.format(Main.MLG_Last_Modified_Date);
final String PROG_NAME = Main.PROG_NAME;
final String VERSION = Main.VERSION;
String showHelpSTR = "";
String ReadMeText = "";
String VersionInfo = "";
//@formatter:off
ReadMeText = PROG_NAME + " version " + VERSION + newLine
+ newLine
+ "Updated " + MLG_Last_Modified_MDY + newLine
+ "(BuildID: " + Main.MLG_Last_Modified_Date.getTime() + ")" + newLine
+ newLine
+ "Original Code by Corrodias November 2010" + newLine
+ "Enhanced Code by Morlok8k Feb. 2011 to Now (or at least to " + MLG_Last_Modified_MDY + "!)" + newLine
+ "Additional Code by pr0f1x October 2011" + newLine
+ newLine
+ "Website: https://sites.google.com/site/minecraftlandgenerator/" + newLine
+ "Forum: http://www.minecraftforum.net/topic/187737-minecraft-land-generator/" + newLine
+ "Source: https://github.com/Morlok8k/MinecraftLandGenerator" + newLine
+ newLine
+ "-----------------------------------------------" + newLine
+ newLine
+ "This program lets you generate an area of land with your Minecraft Beta SMP server (and is prossibly future-proof for newer versions). You set up your java command line and minecraft server paths in the MinecraftLandGenerator.conf file, set up the server's server.properties file with the name of the world you wish to use, and then run this program." + newLine
+ "When a Minecraft server is launched, it automatically generates chunks within a square area of 25x25 chunks (400x400 blocks), centered on the current spawn point (formally 20x20 chunks, 320x320 blocks). When provided X and Z ranges as arguments, this program will launch the server repeatedly, editing the level.dat file between sessions, to generate large amounts of land without players having to explore them. The generated land will have about the X and Z ranges as requested by the arguments, though it will not be exact due to the spawn point typically not on the border of a chunk. (Because of this, MLG by default adds a slight overlap with each pass - 380x380 blocks) You can use the -x and -z switches to override the spawn offset and center the land generation on a different point." + newLine
+ "The program makes a backup of level.dat as level_backup.dat before editing, and restores the backup at the end. In the event that a level_backup.dat file already exists, the program will refuse to proceed, leaving the user to determine why the level_backup.dat file exists and whether they would rather restore it or delete it, which must be done manually." + newLine
+ newLine
+ "This program is public domain, and the source code is included in the .jar file. (If accidently missing, like in 1.3.0 and 1.4.0, it is always available at Github.)" + newLine
+ "The JNLP library is included (inside the .jar). It is not public domain. Its license is included, as LICENSE.TXT." + newLine
+ "It is also available at: http://jnbt.sourceforge.net/" + newLine
+ newLine
+ "The \"unescape\" method/function is also not Public Domain. Its License is the W3C\u00A9 Software License, and located here: http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231"
+ newLine
+ "Other Public Domain code has been used in this program, and references to sources are included in the comments of " + PROG_NAME + "'s source code."
+ newLine
+ "-----------------------------------------------" + newLine
+ newLine;
//@formatter:on
showHelpSTR = showHelp(false); //stored as a string for easier manipulation in the future
//@formatter:off
VersionInfo = newLine
+ "-----------------------------------------------" + newLine
+ newLine
+ "Version History:" + newLine
+ "Morlok8k:" + newLine
+ "1.7.0" + newLine
+ "- Major Code Optimization" + newLine
+ "- Drastically reduced the amount of time it takes for MLG to expand a world after it has already done so before!" + newLine
+ " (To do this, I rewrote the Main loop of the program, and add my own Coordinate object)" + newLine
+ "- Added Resume Functionality" + newLine
+ "- Updated Time Output yet again." + newLine
+ "- Made xx% output nicer by rewriting previous existing line." + newLine
+ "- Misc. Tweaks" + newLine
+ "- Misc. Additions" + newLine
+ "1.6.3" + newLine
+ "- Minor Code Optimization" + newLine
+ "- Finely got on the ball and added the JNBT source and everything (as an internal .zip) to be completely faithful to his license" + newLine
+ "- Also adding script files internally in the .jar for archive (or offline) purposes. (Manual Extract needed for use)" + newLine
+ "- Modified output of MLG slightly to show whats the server and whats MLG. (I may do more with this later.)" + newLine
+ "1.6.2" + newLine
+ "- Major Code Optimization" + newLine
+ "- 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
+ "- Updated Time Output." + newLine
+ "- Changed estimated time remaining to count all runs, not just the last four." + newLine
+ "- Added the time it took to complete at the end of generation." + newLine
+ newLine
+ "1.6.1" + newLine
+ "- Added some modifications for scripting (Mainly for a new Initial setup script)" + newLine
+ "- Changed MLG's Y to Z. Now it matches Minecraft. Y in the game is Height." + newLine
+ "- Renamed -y switch to -z. MLG will remain backwards compatible if you use the old -y switch." + newLine
+ "- Updated -printspawn to show X,Y,Z" + newLine
+ "- Added End-of-Generation ASCII-Graphic" + newLine
+ "- Slightly altered some text output" + newLine
+ newLine
+ "1.6.05" + newLine
+ "- MLG displays if the server is converting the Map format, when not in verbose mode. (McRegion -> Anvil, or Chunk-File -> McRegion)" + newLine
+ "- Minor fixes/edits/typos" + newLine
+ "- Added link to new MLG website to readme file"
+ newLine
+ "1.6.03" + newLine
+ "- added decoding of escape characters of URL's (so a space is a \" \" and not \"%20\")" + newLine
+ "- added \"-downloadlist [list]\" where [list] is a text file with URL's on each line" + newLine
+ newLine
+ "1.6.02" + newLine
+ "- small fix on caculating md5sum where old version didnt pad out to 32chars with zeros on the left side"
+ "- quick Archive intergity fix after injecting source code into .jar after it compiled."
+ "- no new functionality, md5 issue doesnt affect -update on old versions."
+ newLine
+ "1.6.0" + newLine
+ "- NOW DOES NOT NEED ANY SCRIPT FILES!" + newLine
+ "- Added the ability to download files from the internet" + newLine
+ "- Added a switch to download any file off the internet, if needed (useless for most people, but included it in case I wanted it in the future.)" + newLine
+ "- Added the ability to check what version the .jar is. (Using MD5 hashes, timestamps, and the BuildID file)" + newLine
+ "- Added \"-update\" to download new versions of MLG directly from github." + newLine
+ "- Updated estimated time. Now shows up on loop 2+ instead of loop 4+." + newLine
+ "- Standard % output of the Server should look nicer now." + newLine
+ "- Code Refactoring" + newLine
+ "- Code Formatting" + newLine
+ "- Code Optimization" + newLine
+ "- Duplicate sections of code have been turned into Methods/\"Functions\"" + newLine
+ newLine
+ "1.5.1" + newLine
+ "- pr0f1x: Added the \"save-all\" command to be sent to the server before shutting it down." + newLine
+ "- pr0f1x: Added a 40 second wait before shutting down." + newLine
+ "- Morlok8k: Made 40 second wait optional." + newLine
+ "- Morlok8k: Changed the Dimensions code. (I had assumed it would be DIM-1, DIM-2, etc. but it turned out to be DIM-1 and DIM1. Change reflects Server output of \"Level n\")" + newLine
+ "- Morlok8k: Config file is automatically updated to reflect these changes." + newLine
+ "- Morlok8k: Cleaned up code." + newLine
+ newLine
+ "1.5.0" + newLine
+ "- Supports Server Beta 1.6.4 (& hopefully future versions as well, while remaining backward compatible.)" + newLine
+ "- Added \"-a\",\"-alt\" to use alternate method (a slightly simplier version of 1.3.0's code - pure verbose only)" + newLine
+ "- Added world specific output for 9 dimensions (DIM-1 is the Nether, DIM-2 through DIM-9 dont exist yet, but if and when they do, you can configure it's text). (\"Level 0\", the default world, is displayed as the worlds name)" + newLine
+ "- Updated Config File for these Dimensions." + newLine
+ "- Reads and outputs the Seed to the output. (If you had used text for the Seed, Minecraft converts it into a number. This outputs the number.)" + newLine
+ "- Changed the default 300 blocks to 380. The server now makes a 400x400 square block terrain instead of 320x320. Thus it is faster because there are less loops. To use the old way, use \"-i300\"" + newLine
+ "- Added total Percentage done (technically, it displays the % done once the server finishes...)" + newLine
+ "- Added debugging output vars of conf file (disabled - need to re-compile source to activate)" + newLine
+ newLine
+ "\t\t+ (the goal is to have MLG be configureable, so it can work on any version of the server, past or present.)" + newLine
+ newLine
+ "*** 1.4.5 (pre 1.5.0) ***" + newLine
+ "- sorry! I shouldn't release untested code..." + newLine
+ "*************************" + newLine
+ newLine
+ "1.4.4" + newLine
+ "- Added ablilty to ignore [WARNING] and [SEVERE] errors with \"-w\"" + newLine
+ newLine
+ "1.4.3" + newLine
+ "- Fixed \"-ps\",\"-printspawn\" as I had forgot I had broken it in 1.4.0 - due to config file change." + newLine
+ newLine
+ "1.4.2" + newLine
+ "- No New Features" + newLine
+ "- Changed non-verbose mode to display server progress on the same line, saving a lot of space." + newLine
+ " - This couldn't wait for 1.5.0 ... I (Morlok8k) liked it too much." + newLine
+ newLine
+ "1.4.0" + newLine
+ "- Future Proofing" + newLine
+ "- Configurble Server Message reading. (If server updates and breaks MLG, you can add the new text!)" + newLine
+ "- Updated config file, and auto updating from old format." + newLine
+ "- Added % of spawn area to non-verbose output." + newLine
+ "- Removed datetime stamps from server output in verbose mode" + newLine
+ "- Other Misc fixes." + newLine
+ newLine
+ "1.3.0" + newLine
+ "- Fixed Problems with Minecraft Beta 1.3 -- Morlok8k" + newLine
+ newLine
+ "-----------------------------------------------" + newLine
+ newLine
+ "Corrodias:" + newLine
+ "1.2.0" + newLine
+ "- land generation now centers on the spawn point instead of [0, 0]" + newLine
+ "- the server is launched once before the spawn point is changed, to verify that it can run and to create a world if one doesn't exist" + newLine
+ "- added -printspawn [-ps] switch to print the current spawn coordinates to the console" + newLine
+ "- added -x and -y switches to override the X and Y offsets" + newLine
+ "- added -v switch, does the same as -verbose" + newLine
+ "- improved status message spacing to make things easier to read" + newLine
+ "- improved time estimation algorithm: it now averages the last 3 launches" + newLine
+ newLine
+ "1.1.0" + newLine
+ "- added MinecraftLandGenerator.conf file to hold the java command line and the server path" + newLine
+ "- added -conf solo switch to generate a .conf file" + newLine
+ "- added -verbose switch to output server output to the console (default is to ignore it)" + newLine
+ "- added -i switch to allow customizing the block increment size (default is 300)" + newLine
+ "- added instructions output in this version, i think" + newLine
+ "- improved status message output to include current iteration and total iterations" + newLine
+ newLine
+ "1.0.0" + newLine
+ "- initial release" + newLine
+ newLine
+ "-----------------------------------------------" + newLine
+ newLine
+ "Notes:" + newLine
+ "Due to changes in server beta 1.6, it now generates the nether as well as the world at the same time." + newLine
+ "However, Since beta 1.9 and Minecraft 1.0, the nether or the end is no longer generated."
+ "I recommend using MCEDIT to relight the map after you generate it. This will take a long time, but should fix all those incorrectly dark spots in your level." + newLine;
//@formatter:on
FileWrite.writeTxtFile(readmeFile, ReadMeText + showHelpSTR + VersionInfo);
}
/**
* Displays or returns Help information
*
* @param SysOut
* <br>
* Set TRUE to display info to System.out. (Returns null) <br>
* Set FALSE to return info as String.
* @author Morlok8k
*/
public static String showHelp(final boolean SysOut) {
String Str = null;
String NewLine = newLine;
if (SysOut) {
NewLine = NewLine + Main.MLG;
}
MLGFileNameShort = Main.MLGFileNameShort;
MinecraftLandGeneratorConf = Main.MinecraftLandGeneratorConf;
defaultReadmeFile = Main.defaultReadmeFile;
//@formatter:off
Str = "Usage: java -jar " + MLGFileNameShort + " x z [serverpath] [switches]" + NewLine
+ NewLine
+ "Arguments:" + NewLine
+ " x : X range to generate" + NewLine
+ " z : Z range to generate" + NewLine
+ " serverpath : the path to the directory in which the server runs (takes precedence over the config file setting)" + NewLine
+ NewLine
+ "Switches:" + NewLine
+ " -verbose : causes the application to output the server's messages to the console" + NewLine
+ " -v : same as -verbose" + NewLine
+ " -w : Ignore [WARNING] and [SEVERE] messages." + NewLine
+ " -alt : alternate server launch sequence" + NewLine
+ " -a : same as -alt" + NewLine
+ " -nowait : don't pause for anything" + NewLine
+ " -n : same as -nowait" + NewLine
+ " -i# : override the iteration spawn offset increment (default 380) (example: -i100)" + NewLine
+ " -x# : set the X offset to generate land around (example: -x0 or -x1000 or -x-500)" + NewLine
+ " -z# : set the Z offset to generate land around (example: -z0 or -z1000 or -z-500)" + NewLine
+ NewLine
+ "Other options:" + NewLine
+ " java -jar " + MLGFileNameShort + " -update" + NewLine
+ " Checks for and downloads new versions of MLG online." + NewLine
+ NewLine
+ " java -jar " + MLGFileNameShort + " -printspawn" + NewLine
+ " java -jar " + MLGFileNameShort + " -ps" + NewLine
+ " Outputs the current world's spawn point coordinates." + NewLine
+ NewLine
+ " java -jar " + MLGFileNameShort + " -conf" + NewLine
+ " java -jar " + MLGFileNameShort + " -conf download" + NewLine
+ " Generates or downloads a "+ MinecraftLandGeneratorConf + " file." + NewLine
+ NewLine
+ " java -jar " + MLGFileNameShort + " -readme readme.txt" + NewLine
+ " java -jar " + MLGFileNameShort + " -readme" + NewLine
+ " Generates a readme file using supplied name or the default " + defaultReadmeFile + NewLine
+ NewLine
+ " java -jar " + MLGFileNameShort + " -downloadfile http://example.com/file.txt" + NewLine
+ " Downloads whatever file from the internet you give it." + NewLine
+ " java -jar " + MLGFileNameShort + " -downloadlist list.txt" + NewLine
+ " list.txt (or any other file) contains a URL on each line which will be downloaded." + NewLine
+ NewLine
+ " java -jar " + MLGFileNameShort + " -version" + NewLine
+ " java -jar " + MLGFileNameShort + " -help" + NewLine
+ " java -jar " + MLGFileNameShort + " /?" + NewLine
+ " Prints this message." + NewLine
+ NewLine
+ "When launched with the -conf switch, this application creates a " + MinecraftLandGeneratorConf + " file that contains configuration options." + NewLine
+ "If this file does not exist or does not contain all required properties, the application will not run." + NewLine
+ NewLine
+ MinecraftLandGeneratorConf + " properties:" + NewLine
+ " Java : The command line to use to launch the server" + NewLine
+ " ServerPath : The path to the directory in which the server runs (can be overridden by the serverpath argument)" + NewLine
+ " Done_Text : The output from the server that tells us that we are done" + NewLine
+ " Preparing_Text : The output from the server that tells us the percentage" + NewLine
+ "Preparing_Level : The output from the server that tells us the level it is working on" + NewLine
+ " Level-0 : Name of Level 0: The Overworld" + NewLine
+ " Level-1 : Name of Level 1: The Nether" + NewLine
+ " Level-2 : Name of Level 2: The End" + NewLine
+ " Level-3 : Name of Level 3: (Future Level)" + NewLine
+ " Level-4 : Name of Level 4: (Future Level)" + NewLine
+ " Level-5 : Name of Level 5: (Future Level)" + NewLine
+ " Level-6 : Name of Level 6: (Future Level)" + NewLine
+ " Level-7 : Name of Level 7: (Future Level)" + NewLine
+ " Level-8 : Name of Level 8: (Future Level)" + NewLine
+ " Level-9 : Name of Level 9: (Future Level)" + NewLine
+ " WaitSave : Optional: Wait before saving." + NewLine;
//@formatter:on
String returnString = null;
if (SysOut) {
Main.out(Str);
Main.out("");
} else {
returnString = Str;
}
return returnString;
}
}

View File

@ -1,19 +1,18 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean; import java.lang.management.RuntimeMXBean;
import java.util.List; import java.util.List;
import corrodias.minecraft.landgenerator.Main;
public class MLG_SelfAware { public class SelfAware {
public static String JVMinfo() { public static String JVMinfo() {
String Return = ""; String Return = "";
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean(); final RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
List<String> aList = RuntimemxBean.getInputArguments(); final List<String> aList = RuntimemxBean.getInputArguments();
for (int i = 0; i < aList.size(); i++) { for (int i = 0; i < aList.size(); i++) {
Return = Return + (aList.get(i)) + " "; Return = Return + (aList.get(i)) + " ";

View File

@ -1,11 +1,11 @@
package corrodias.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
public class MLG_Server { 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 * 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
@ -16,7 +16,7 @@ public class MLG_Server {
* @throws IOException * @throws IOException
* @author Corrodias * @author Corrodias
*/ */
protected static boolean runMinecraft(boolean alternate) throws IOException { protected static boolean runMinecraft(final boolean alternate) throws IOException {
if (Main.verbose) { if (Main.verbose) {
Main.out("Starting server."); Main.out("Starting server.");
} }
@ -30,21 +30,21 @@ public class MLG_Server {
if (alternate) { // Alternate - a replication (slightly stripped down) of MLG 1.3.0's code. simplest code possible. if (alternate) { // Alternate - a replication (slightly stripped down) of MLG 1.3.0's code. simplest code possible.
Main.out("Alternate Launch"); Main.out("Alternate Launch");
Process process = Main.minecraft.start(); final Process process = Main.minecraft.start();
//byte[] saveAll = { 's', 'a', 'v', 'e', '-', 'a', 'l', 'l', '\r', '\n' }; //byte[] saveAll = { 's', 'a', 'v', 'e', '-', 'a', 'l', 'l', '\r', '\n' };
byte[] stop = { 's', 't', 'o', 'p', '\r', '\n' }; final byte[] stop = { 's', 't', 'o', 'p', '\r', '\n' };
// monitor output and print to console where required. // monitor output and print to console where required.
// STOP the server when it's done. // STOP the server when it's done.
BufferedReader pOut = final BufferedReader pOut =
new BufferedReader(new InputStreamReader(process.getInputStream())); new BufferedReader(new InputStreamReader(process.getInputStream()));
String line; String line;
while ((line = pOut.readLine().trim()) != null) { // readLine() returns null when the process exits while ((line = pOut.readLine().trim()) != null) { // readLine() returns null when the process exits
System.out.println(line); System.out.println(line);
if (line.contains(Main.doneText)) { // EDITED By Morlok8k for Minecraft 1.3+ Beta if (line.contains(Main.doneText)) { // EDITED By Morlok8k for Minecraft 1.3+ Beta
OutputStream outputStream = process.getOutputStream(); final OutputStream outputStream = process.getOutputStream();
Main.out("Stopping server... (Please Wait...)"); Main.out("Stopping server... (Please Wait...)");
outputStream.write(stop); outputStream.write(stop);
@ -55,11 +55,11 @@ public class MLG_Server {
// End while loop // End while loop
} else { // start minecraft server normally! } else { // start minecraft server normally!
Process process = Main.minecraft.start(); final Process process = Main.minecraft.start();
if (Main.verbose) { if (Main.verbose) {
Main.out("Started Server."); Main.out("Started Server.");
} }
BufferedReader pOut = final BufferedReader pOut =
new BufferedReader(new InputStreamReader(process.getInputStream())); new BufferedReader(new InputStreamReader(process.getInputStream()));
if (Main.verbose) { if (Main.verbose) {
Main.out("Accessing Server Output..."); Main.out("Accessing Server Output...");
@ -70,20 +70,20 @@ public class MLG_Server {
String outTmp = ""; String outTmp = "";
String outTmp2 = null; String outTmp2 = null;
byte[] stop = { 's', 't', 'o', 'p', '\r', '\n' }; // Moved here, so this code wont run every loop, thus Faster! final byte[] stop = { 's', 't', 'o', 'p', '\r', '\n' }; // Moved here, so 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' }; final byte[] saveAll = { 's', 'a', 'v', 'e', '-', 'a', 'l', 'l', '\r', '\n' };
boolean prepTextFirst = true; boolean prepTextFirst = true;
OutputStream outputStream = process.getOutputStream(); // moved here to remove some redundancy final OutputStream outputStream = process.getOutputStream(); // moved here to remove some redundancy
boolean convertedMapFormattingFlag = false; // This allows MLG to track if we converted a map to a new format (such as Chunk-file -> McRegion, or McRegion -> Anvil) boolean convertedMapFormattingFlag = false; // This allows MLG to track if we converted a map to a new format (such as Chunk-file -> McRegion, or McRegion -> Anvil)
// just so it gets a line ending after the % output finishes // just so it gets a line ending after the % output finishes
while ((line = pOut.readLine().trim()) != null) { // readLine() returns null when the process exits while ((line = pOut.readLine().trim()) != null) { // readLine() returns null when the process exits
int posBracket = line.indexOf("]"); //changed from .lastIndexOf to .indexOf, in case we have a custom server that outputs something with an "]". we want the first one anyways. final int posBracket = line.indexOf("]"); //changed from .lastIndexOf to .indexOf, in case we have a custom server that outputs something with an "]". we want the first one anyways.
if (posBracket != -1) { if (posBracket != -1) {
shortLine = line.substring(posBracket + 2); shortLine = line.substring(posBracket + 2);
shortLine = shortLine.trim(); shortLine = shortLine.trim();
@ -182,7 +182,7 @@ public class MLG_Server {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (final InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
count += 1; count += 1;
@ -207,7 +207,7 @@ public class MLG_Server {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (final InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
count += 1; count += 1;

View File

@ -1,4 +1,4 @@
package corrodias.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -8,7 +8,6 @@ import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import morlok8k.minecraft.landgenerator.Coordinates;
import org.jnbt.CompoundTag; import org.jnbt.CompoundTag;
import org.jnbt.IntTag; import org.jnbt.IntTag;
@ -17,7 +16,7 @@ import org.jnbt.NBTInputStream;
import org.jnbt.NBTOutputStream; import org.jnbt.NBTOutputStream;
import org.jnbt.Tag; import org.jnbt.Tag;
public class MLG_SpawnPoint { public class SpawnPoint {
/** /**
* Changes the spawn point in the given Alpha/Beta level to the given coordinates.<br> * Changes the spawn point in the given Alpha/Beta level to the given coordinates.<br>
@ -32,11 +31,11 @@ public class MLG_SpawnPoint {
* if there are any problems reading/writing the file * if there are any problems reading/writing the file
* @author Corrodias * @author Corrodias
*/ */
protected static void setSpawn(File level, Coordinates xyz) throws IOException { protected static void setSpawn(final File level, final Coordinates xyz) throws IOException {
try { try {
NBTInputStream input = new NBTInputStream(new FileInputStream(level)); final NBTInputStream input = new NBTInputStream(new FileInputStream(level));
CompoundTag originalTopLevelTag = (CompoundTag) input.readTag(); final CompoundTag originalTopLevelTag = (CompoundTag) input.readTag();
input.close(); input.close();
//@formatter:off //@formatter:off
@ -69,35 +68,35 @@ public class MLG_SpawnPoint {
//@formatter:on //@formatter:on
Map<String, Tag> originalData = final 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 reason, so we have to make a copy. // This is our map of data. It is an unmodifiable map, for some reason, so we have to make a copy.
Map<String, Tag> newData = new LinkedHashMap<String, Tag>(originalData); final Map<String, Tag> newData = new LinkedHashMap<String, Tag>(originalData);
// .get() a couple of values, just to make sure we're dealing with a valid level file, here. Good for debugging, too. // .get() a couple of values, just to make sure we're dealing with a 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. final IntTag spawnX = (IntTag) newData.get("SpawnX"); // we never use these... Its only here for potential debugging.
@SuppressWarnings("unused") @SuppressWarnings("unused")
IntTag spawnY = (IntTag) newData.get("SpawnY"); // but whatever... so I (Morlok8k) suppressed these warnings. final IntTag spawnY = (IntTag) newData.get("SpawnY"); // but whatever... so I (Morlok8k) suppressed these warnings.
@SuppressWarnings("unused") @SuppressWarnings("unused")
IntTag spawnZ = (IntTag) newData.get("SpawnZ"); // I don't want to remove existing code, either by myself (Morlok8k) or Corrodias final IntTag spawnZ = (IntTag) newData.get("SpawnZ"); // I don't want to remove existing code, either by myself (Morlok8k) or Corrodias
newData.put("SpawnX", new IntTag("SpawnX", xyz.getX())); // pulling the data out of the Coordinates, newData.put("SpawnX", new IntTag("SpawnX", xyz.getX())); // pulling the data out of the Coordinates,
newData.put("SpawnY", new IntTag("SpawnY", xyz.getY())); // and putting it into our IntTag's newData.put("SpawnY", new IntTag("SpawnY", xyz.getY())); // and putting it into our IntTag's
newData.put("SpawnZ", new IntTag("SpawnZ", xyz.getZ())); newData.put("SpawnZ", new IntTag("SpawnZ", xyz.getZ()));
// Again, we can't modify the data map in the old Tag, so we have to make a new one. // Again, we can't modify the data map in the old Tag, so we have to make a new one.
CompoundTag newDataTag = new CompoundTag("Data", newData); final CompoundTag newDataTag = new CompoundTag("Data", newData);
Map<String, Tag> newTopLevelMap = new HashMap<String, Tag>(1); final Map<String, Tag> newTopLevelMap = new HashMap<String, Tag>(1);
newTopLevelMap.put("Data", newDataTag); newTopLevelMap.put("Data", newDataTag);
CompoundTag newTopLevelTag = new CompoundTag("", newTopLevelMap); final CompoundTag newTopLevelTag = new CompoundTag("", newTopLevelMap);
NBTOutputStream output = new NBTOutputStream(new FileOutputStream(level)); final NBTOutputStream output = new NBTOutputStream(new FileOutputStream(level));
output.writeTag(newTopLevelTag); output.writeTag(newTopLevelTag);
output.close(); output.close();
} catch (ClassCastException ex) { } catch (final ClassCastException ex) {
throw new IOException("Invalid level format."); throw new IOException("Invalid level format.");
} catch (NullPointerException ex) { } catch (final NullPointerException ex) {
throw new IOException("Invalid level format."); throw new IOException("Invalid level format.");
} }
} }
@ -109,33 +108,33 @@ public class MLG_SpawnPoint {
* @throws IOException * @throws IOException
* @author Corrodias * @author Corrodias
*/ */
protected static Coordinates getSpawn(File level) throws IOException { protected static Coordinates getSpawn(final File level) throws IOException {
try { try {
NBTInputStream input = new NBTInputStream(new FileInputStream(level)); final NBTInputStream input = new NBTInputStream(new FileInputStream(level));
CompoundTag originalTopLevelTag = (CompoundTag) input.readTag(); final CompoundTag originalTopLevelTag = (CompoundTag) input.readTag();
input.close(); input.close();
Map<String, Tag> originalData = final 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); final 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.
IntTag spawnX = (IntTag) newData.get("SpawnX"); final IntTag spawnX = (IntTag) newData.get("SpawnX");
IntTag spawnY = (IntTag) newData.get("SpawnY"); final IntTag spawnY = (IntTag) newData.get("SpawnY");
IntTag spawnZ = (IntTag) newData.get("SpawnZ"); final IntTag spawnZ = (IntTag) newData.get("SpawnZ");
LongTag Seed = (LongTag) newData.get("RandomSeed"); final LongTag Seed = (LongTag) newData.get("RandomSeed");
Main.randomSeed = Seed.getValue(); Main.randomSeed = Seed.getValue();
Main.out("Seed: " + Main.randomSeed); // lets output the seed, cause why not? Main.out("Seed: " + Main.randomSeed); // lets output the seed, cause why not?
Coordinates ret = final Coordinates ret =
new Coordinates(spawnX.getValue(), spawnY.getValue(), spawnZ.getValue()); new Coordinates(spawnX.getValue(), spawnY.getValue(), spawnZ.getValue());
return ret; return ret;
} catch (ClassCastException ex) { } catch (final ClassCastException ex) {
throw new IOException("Invalid level format."); throw new IOException("Invalid level format.");
} catch (NullPointerException ex) { } catch (final NullPointerException ex) {
throw new IOException("Invalid level format."); throw new IOException("Invalid level format.");
} }
} }

View File

@ -1,15 +1,15 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
public class MLG_StringArrayParse { public class StringArrayParse {
public static String[] Parse(String[] array, String ParseOut) { public static String[] Parse(final String[] array, final String ParseOut) {
//There is probably a better way to do this. //There is probably a better way to do this.
//We input a String[] array, and a String. //We input a String[] array, and a String.
//if the String matches one inside the array, it gets "deleted" //if the String matches one inside the array, it gets "deleted"
//(actually a new String[] without it is returned) //(actually a new String[] without it is returned)
String[] workingArray = new String[array.length]; //workingArray is our working array. we don't modify the original. final String[] workingArray = new String[array.length]; //workingArray is our working array. we don't modify the original.
boolean removed = false; boolean removed = false;
@ -26,7 +26,7 @@ public class MLG_StringArrayParse {
ii++; ii++;
} }
} catch (Exception ex) { } catch (final Exception ex) {
System.err.println("Something went wrong! (Parsing Error?)"); System.err.println("Something went wrong! (Parsing Error?)");
ex.fillInStackTrace(); ex.fillInStackTrace();
return array; //we got some error... return the original array, just in case. return array; //we got some error... return the original array, just in case.
@ -34,7 +34,7 @@ public class MLG_StringArrayParse {
if (removed) { if (removed) {
// at this point, workingArray has null for its last string. we need to remove it. // at this point, workingArray has null for its last string. we need to remove it.
String[] returnArray = new String[workingArray.length - 1]; final String[] returnArray = new String[workingArray.length - 1];
for (int i = 0; i < returnArray.length; i++) { for (int i = 0; i < returnArray.length; i++) {
returnArray[i] = workingArray[i]; returnArray[i] = workingArray[i];
} }

View File

@ -1,15 +1,14 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import corrodias.minecraft.landgenerator.Main;
public class MLG_Time { public class Time {
/** /**
* waits ten seconds. outputs 10%, 20%, etc after each second. * waits ten seconds. outputs 10%, 20%, etc after each second.
* *
* @author Morlok8k * @author Morlok8k
*/ */
public static void waitTenSec(boolean output) { public static void waitTenSec(final boolean output) {
if (Main.dontWait) { return; } //Don't wait! if (Main.dontWait) { return; } //Don't wait!
@ -25,7 +24,7 @@ public class MLG_Time {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (final InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
count += 10; count += 10;
@ -45,11 +44,11 @@ public class MLG_Time {
* @author Morlok8k * @author Morlok8k
* @return String of Readable Time * @return String of Readable Time
*/ */
public static String displayTime(long startTimeMillis, long endTimeMillis) { public static String displayTime(final long startTimeMillis, final long endTimeMillis) {
long millis = (endTimeMillis - startTimeMillis); final long millis = (endTimeMillis - startTimeMillis);
//I just duplicated displayTime to have a start & end times, because it just made things simpler to code. //I just duplicated displayTime to have a start & end times, because it just made things simpler to code.
return (MLG_Time.displayTime(millis)); return (Time.displayTime(millis));
} }
/** /**
@ -59,13 +58,13 @@ public class MLG_Time {
* @author Morlok8k * @author Morlok8k
* @return String of Readable Time * @return String of Readable Time
*/ */
public static String displayTime(long timeMillis) { public static String displayTime(final long timeMillis) {
long seconds = timeMillis / 1000; final long seconds = timeMillis / 1000;
long minutes = seconds / 60; final long minutes = seconds / 60;
long hours = minutes / 60; final long hours = minutes / 60;
long days = hours / 24; final long days = hours / 24;
long years = days / 365; final long years = days / 365;
String took = String took =
(years > 0 ? String.format("%d " + ((years) == 1 ? "Year, " : "Years, "), years) (years > 0 ? String.format("%d " + ((years) == 1 ? "Year, " : "Years, "), years)
@ -81,8 +80,8 @@ public class MLG_Time {
seconds % 60); seconds % 60);
if (!(Main.verbose)) { if (!(Main.verbose)) {
int commaFirst = took.indexOf(","); final int commaFirst = took.indexOf(",");
int commaSecond = took.substring((commaFirst + 1), took.length()).indexOf(","); final int commaSecond = took.substring((commaFirst + 1), took.length()).indexOf(",");
int end = (commaFirst + 1 + commaSecond); int end = (commaFirst + 1 + commaSecond);
if (commaSecond == -1) { if (commaSecond == -1) {

View File

@ -1,4 +1,4 @@
package morlok8k.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -16,10 +16,8 @@ import java.util.Iterator;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import corrodias.minecraft.landgenerator.MLG_Misc;
import corrodias.minecraft.landgenerator.Main;
public class MLG_Update { public class Update {
/** /**
* This is an "undocumented" function to create a BuildID file. It should only be used right after compiling a .jar file<br> * This is an "undocumented" function to create a BuildID file. It should only be used right after compiling a .jar file<br>
@ -34,11 +32,11 @@ public class MLG_Update {
* *
* @author Morlok8k * @author Morlok8k
*/ */
public static void buildID(boolean downloadOnly) { public static void buildID(final boolean downloadOnly) {
// download BuildID from Github. // download BuildID from Github.
boolean fileSuccess = final boolean fileSuccess =
MLG_DownloadFile.downloadFile(Main.github_MLG_BuildID_URL, Main.testing); DownloadFile.downloadFile(Main.github_MLG_BuildID_URL, Main.testing);
if (fileSuccess) { if (fileSuccess) {
Main.out(Main.buildIDFile + " file downloaded."); Main.out(Main.buildIDFile + " file downloaded.");
Main.flag_downloadedBuildID = true; Main.flag_downloadedBuildID = true;
@ -58,7 +56,7 @@ public class MLG_Update {
if (Main.MLGFileName == null) { if (Main.MLGFileName == null) {
try { try {
Main.MLGFileName = getClassLoader(Main.cls); Main.MLGFileName = getClassLoader(Main.cls);
} catch (Exception e) { } catch (final Exception e) {
Main.out("Error: Finding file failed"); Main.out("Error: Finding file failed");
e.printStackTrace(); e.printStackTrace();
} }
@ -68,10 +66,10 @@ public class MLG_Update {
if (Main.MLG_Current_Hash == null) { if (Main.MLG_Current_Hash == null) {
try { try {
Main.MLG_Current_Hash = MLG_MD5.fileMD5(Main.MLGFileName); Main.MLG_Current_Hash = MD5.fileMD5(Main.MLGFileName);
// out(hash + " " + MLGFileName); // out(hash + " " + MLGFileName);
} catch (Exception e) { } catch (final Exception e) {
Main.out("Error: MLG_MD5 from file failed"); Main.out("Error: MD5 from file failed");
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -80,7 +78,7 @@ public class MLG_Update {
try { try {
time = getCompileTimeStamp(Main.cls); time = getCompileTimeStamp(Main.cls);
} catch (Exception e) { } catch (final Exception e) {
Main.out("Error: TimeStamp from file failed"); Main.out("Error: TimeStamp from file failed");
e.printStackTrace(); e.printStackTrace();
} }
@ -95,8 +93,9 @@ public class MLG_Update {
try { try {
String line; String line;
BufferedReader inFile = new BufferedReader(new FileReader(Main.buildIDFile)); final BufferedReader inFile = new BufferedReader(new FileReader(Main.buildIDFile));
BufferedWriter outFile = new BufferedWriter(new FileWriter(Main.buildIDFile + ".temp")); final BufferedWriter outFile =
new BufferedWriter(new FileWriter(Main.buildIDFile + ".temp"));
while ((line = inFile.readLine()) != null) { while ((line = inFile.readLine()) != null) {
@ -119,20 +118,20 @@ public class MLG_Update {
outFile.close(); outFile.close();
inFile.close(); inFile.close();
File fileDelete = new File(Main.buildIDFile); final File fileDelete = new File(Main.buildIDFile);
fileDelete.delete(); fileDelete.delete();
File fileRename = new File(Main.buildIDFile + ".temp"); final File fileRename = new File(Main.buildIDFile + ".temp");
fileRename.renameTo(new File(Main.buildIDFile)); fileRename.renameTo(new File(Main.buildIDFile));
} catch (FileNotFoundException ex) { } catch (final FileNotFoundException ex) {
Main.out("\"" + Main.buildIDFile + "\" file not Found. Generating New \"" Main.out("\"" + Main.buildIDFile + "\" file not Found. Generating New \""
+ Main.buildIDFile + "\" File"); + Main.buildIDFile + "\" File");
MLG_FileWrite.writeTxtFile(Main.buildIDFile, FileWrite.writeTxtFile(Main.buildIDFile,
Main.MLG_Current_Hash + "=" + String.valueOf(time.getTime()) + "#MLG v" Main.MLG_Current_Hash + "=" + String.valueOf(time.getTime()) + "#MLG v"
+ Main.VERSION + INFO); + Main.VERSION + INFO);
} catch (IOException ex) { } catch (final IOException ex) {
Main.err("Could not create \"" + Main.buildIDFile + "\"."); Main.err("Could not create \"" + Main.buildIDFile + "\".");
return; return;
} }
@ -156,7 +155,7 @@ public class MLG_Update {
if (Main.MLGFileName == null) { if (Main.MLGFileName == null) {
try { try {
Main.MLGFileName = getClassLoader(Main.cls); Main.MLGFileName = getClassLoader(Main.cls);
} catch (Exception e) { } catch (final Exception e) {
Main.out("Error: Finding file failed"); Main.out("Error: Finding file failed");
e.printStackTrace(); e.printStackTrace();
} }
@ -174,10 +173,10 @@ public class MLG_Update {
if (Main.MLG_Current_Hash == null) { if (Main.MLG_Current_Hash == null) {
try { try {
Main.MLG_Current_Hash = MLG_MD5.fileMD5(Main.MLGFileName); Main.MLG_Current_Hash = MD5.fileMD5(Main.MLGFileName);
// out(hash + " " + MLGFileName); // out(hash + " " + MLGFileName);
} catch (Exception e) { } catch (final Exception e) {
Main.out("Error: MLG_MD5 from file failed"); Main.out("Error: MD5 from file failed");
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -189,7 +188,7 @@ public class MLG_Update {
if (Main.MLG_Last_Modified_Date == null) { if (Main.MLG_Last_Modified_Date == null) {
boolean foundLine = false; boolean foundLine = false;
try { try {
BufferedReader in = new BufferedReader(new FileReader(Main.buildIDFile)); final BufferedReader in = new BufferedReader(new FileReader(Main.buildIDFile));
String line; String line;
if (Main.testing) { if (Main.testing) {
@ -239,9 +238,9 @@ public class MLG_Update {
new Long(line.substring(pos + 1, end)); new Long(line.substring(pos + 1, end));
Main.MLG_Last_Modified_Date = new Date(Main.MLG_Last_Modified_Long); Main.MLG_Last_Modified_Date = new Date(Main.MLG_Last_Modified_Long);
Long highestModTime = final Long highestModTime =
MLG_Update.ZipGetModificationTime(Main.MLGFileName); Update.ZipGetModificationTime(Main.MLGFileName);
long tCalc = Main.MLG_Last_Modified_Long - highestModTime; final long tCalc = Main.MLG_Last_Modified_Long - highestModTime;
if (Main.testing) { if (Main.testing) {
Main.outD("tCalc\tMLG_Last_Modified_Long\thighestModTime" Main.outD("tCalc\tMLG_Last_Modified_Long\thighestModTime"
@ -293,7 +292,7 @@ public class MLG_Update {
readBuildID(); // yes I'm calling the function from itself. potential infinite loop? possibly. I haven't encountered it yet! readBuildID(); // yes I'm calling the function from itself. potential infinite loop? possibly. I haven't encountered it yet!
return; return;
} }
} catch (Exception e) { } catch (final Exception e) {
Main.err("Cant Read " + Main.buildIDFile + "!"); Main.err("Cant Read " + Main.buildIDFile + "!");
Main.err(e.getLocalizedMessage()); Main.err(e.getLocalizedMessage());
Main.err(""); Main.err("");
@ -319,7 +318,7 @@ public class MLG_Update {
Main.MLG_Last_Modified_Date = null; Main.MLG_Last_Modified_Date = null;
readBuildID(); readBuildID();
Iterator<String> e = Main.timeStamps.iterator(); final Iterator<String> e = Main.timeStamps.iterator();
String s; String s;
int diff; int diff;
@ -334,18 +333,18 @@ public class MLG_Update {
Main.out("There is a NEW VERSION Of " + Main.PROG_NAME + " available online!"); Main.out("There is a NEW VERSION Of " + Main.PROG_NAME + " available online!");
try { try {
File fileRename = new File(Main.MLG_JarFile); final File fileRename = new File(Main.MLG_JarFile);
fileRename.renameTo(new File(Main.MLG_JarFile + ".old")); fileRename.renameTo(new File(Main.MLG_JarFile + ".old"));
} catch (Exception e1) { } catch (final Exception e1) {
Main.out("Rename attempt #1 failed!"); Main.out("Rename attempt #1 failed!");
e1.printStackTrace(); e1.printStackTrace();
try { try {
MLG_Misc.copyFile(new File(Main.MLG_JarFile), new File(Main.MLG_JarFile Misc.copyFile(new File(Main.MLG_JarFile), new File(Main.MLG_JarFile
+ ".old")); + ".old"));
File fileDelete = new File(Main.MLG_JarFile); final File fileDelete = new File(Main.MLG_JarFile);
fileDelete.delete(); fileDelete.delete();
} catch (Exception e2) { } catch (final Exception e2) {
Main.out("Rename attempt #2 failed!"); Main.out("Rename attempt #2 failed!");
e2.printStackTrace(); e2.printStackTrace();
//renameFailed = true; //renameFailed = true;
@ -354,7 +353,8 @@ public class MLG_Update {
} }
boolean fileSuccess = MLG_DownloadFile.downloadFile(Main.github_MLG_jar_URL, true); final boolean fileSuccess =
DownloadFile.downloadFile(Main.github_MLG_jar_URL, true);
if (fileSuccess) { if (fileSuccess) {
Main.out(Main.MLG_JarFile + " downloaded."); Main.out(Main.MLG_JarFile + " downloaded.");
return; return;
@ -370,10 +370,10 @@ public class MLG_Update {
* *
* @author Morlok8k * @author Morlok8k
*/ */
public static String getClassLoader(Class<?> classFile) throws IOException { public static String getClassLoader(final Class<?> classFile) throws IOException {
ClassLoader loader = classFile.getClassLoader(); final ClassLoader loader = classFile.getClassLoader();
String filename = classFile.getName().replace('.', '/') + ".class"; String filename = classFile.getName().replace('.', '/') + ".class";
URL resource = final URL resource =
(loader != null) ? loader.getResource(filename) : ClassLoader (loader != null) ? loader.getResource(filename) : ClassLoader
.getSystemResource(filename); .getSystemResource(filename);
filename = URLDecoder.decode(resource.toString(), "UTF-8"); filename = URLDecoder.decode(resource.toString(), "UTF-8");
@ -399,7 +399,7 @@ public class MLG_Update {
Main.isCompiledAsJar = true; Main.isCompiledAsJar = true;
} }
filename = filename.replace('/', File.separatorChar); filename = filename.replace('/', File.separatorChar);
String returnString = filename.substring(file, bang); final String returnString = filename.substring(file, bang);
// END Garbage removal // END Garbage removal
return returnString; return returnString;
} }
@ -412,18 +412,18 @@ public class MLG_Update {
* *
* @author Morlok8k * @author Morlok8k
*/ */
public static Date getCompileTimeStamp(Class<?> classFile) throws IOException { public static Date getCompileTimeStamp(final Class<?> classFile) throws IOException {
ClassLoader loader = classFile.getClassLoader(); final ClassLoader loader = classFile.getClassLoader();
String filename = classFile.getName().replace('.', '/') + ".class"; final String filename = classFile.getName().replace('.', '/') + ".class";
// get the corresponding class file as a Resource. // get the corresponding class file as a Resource.
URL resource = final URL resource =
(loader != null) ? loader.getResource(filename) : ClassLoader (loader != null) ? loader.getResource(filename) : ClassLoader
.getSystemResource(filename); .getSystemResource(filename);
URLConnection connection = resource.openConnection(); final URLConnection connection = resource.openConnection();
// Note, we are using Connection.getLastModified not File.lastModifed. // Note, we are using Connection.getLastModified not File.lastModifed.
// This will then work both or members of jars or standalone class files. // This will then work both or members of jars or standalone class files.
// NOTE: NOT TRUE! IT READS THE JAR, NOT THE FILES INSIDE! // NOTE: NOT TRUE! IT READS THE JAR, NOT THE FILES INSIDE!
long time = connection.getLastModified(); final long time = connection.getLastModified();
return (time != 0L) ? new Date(time) : null; return (time != 0L) ? new Date(time) : null;
} }
@ -441,26 +441,26 @@ public class MLG_Update {
* @param timeBuildID * @param timeBuildID
* @author Morlok8k * @author Morlok8k
*/ */
public static Long ZipGetModificationTime(String zipFile) { public static Long ZipGetModificationTime(final String zipFile) {
Long highestModTime = 0L; Long highestModTime = 0L;
try { try {
ZipFile zipF = new ZipFile(zipFile); final ZipFile zipF = new ZipFile(zipFile);
/* /*
* Get list of zip entries using entries method of ZipFile class. * Get list of zip entries using entries method of ZipFile class.
*/ */
Enumeration<? extends ZipEntry> e = zipF.entries(); final Enumeration<? extends ZipEntry> e = zipF.entries();
if (Main.testing) { if (Main.testing) {
Main.outD("File Name\t\tCRC\t\tModification Time\n---------------------------------\n"); Main.outD("File Name\t\tCRC\t\tModification Time\n---------------------------------\n");
} }
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
ZipEntry entry = e.nextElement(); final ZipEntry entry = e.nextElement();
Long modTime = entry.getTime(); Long modTime = entry.getTime();
@ -474,9 +474,9 @@ public class MLG_Update {
if (Main.testing) { if (Main.testing) {
String entryName = entry.getName(); final String entryName = entry.getName();
Date modificationTime = new Date(modTime); final Date modificationTime = new Date(modTime);
String CRC = Long.toHexString(entry.getCrc()); final String CRC = Long.toHexString(entry.getCrc());
Main.outD(entryName + "\t" + CRC + "\t" + modificationTime + "\t" Main.outD(entryName + "\t" + CRC + "\t" + modificationTime + "\t"
+ modTime.toString()); + modTime.toString());
@ -488,7 +488,7 @@ public class MLG_Update {
return highestModTime; return highestModTime;
} catch (IOException ioe) { } catch (final IOException ioe) {
Main.out("Error opening zip file" + ioe); Main.out("Error opening zip file" + ioe);
return 0L; //return Jan. 1, 1970 12:00 GMT for failures return 0L; //return Jan. 1, 1970 12:00 GMT for failures
} }

View File

@ -1,4 +1,4 @@
package corrodias.minecraft.landgenerator; package morlok8k.MinecraftLandGenerator;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@ -8,7 +8,7 @@ import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
public class MLG_WorldVerify { public class WorldVerify {
/** /**
* *
@ -17,7 +17,7 @@ public class MLG_WorldVerify {
//TODO: element comment //TODO: element comment
// verify that we ended up with a good server path, either from the file or from an argument. // verify that we ended up with a good server path, either from the file or from an argument.
File file = new File(Main.serverPath); final File file = new File(Main.serverPath);
if (!file.exists() || !file.isDirectory()) { if (!file.exists() || !file.isDirectory()) {
Main.err("The server directory is invalid: " + Main.serverPath); Main.err("The server directory is invalid: " + Main.serverPath);
return; return;
@ -25,7 +25,7 @@ public class MLG_WorldVerify {
try { try {
// read the name of the current world from the server.properties file // read the name of the current world from the server.properties file
BufferedReader props = final BufferedReader props =
new BufferedReader(new FileReader(new File(Main.serverPath + Main.fileSeparator new BufferedReader(new FileReader(new File(Main.serverPath + Main.fileSeparator
+ "server.properties"))); + "server.properties")));
String line; String line;
@ -98,15 +98,15 @@ public class MLG_WorldVerify {
} }
} }
} catch (FileNotFoundException ex) { } catch (final FileNotFoundException ex) {
Main.err("Could not open " + Main.serverPath + Main.fileSeparator + "server.properties"); Main.err("Could not open " + Main.serverPath + Main.fileSeparator + "server.properties");
return; return;
} catch (IOException ex) { } catch (final IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
return; return;
} }
File level = new File(Main.worldPath + Main.fileSeparator + "level.dat"); final File level = new File(Main.worldPath + Main.fileSeparator + "level.dat");
if (!level.exists() || !level.isFile()) { if (!level.exists() || !level.isFile()) {
Main.err("The currently-configured world does not exist."); Main.err("The currently-configured world does not exist.");
return; return;

View File

@ -1,316 +0,0 @@
package morlok8k.minecraft.landgenerator;
import corrodias.minecraft.landgenerator.Main;
public class MLG_Readme_and_HelpInfo {
static String newLine = Main.newLine;
static String MLGFileNameShort = Main.MLGFileNameShort;
static String MinecraftLandGeneratorConf = Main.MinecraftLandGeneratorConf;
static String defaultReadmeFile = Main.defaultReadmeFile;
/**
* Saves a Readme file.
*
* @param readmeFile
* @author Morlok8k
*
*/
public static void readMe(String readmeFile) {
if (readmeFile == "" || readmeFile == null) {
readmeFile = defaultReadmeFile;
}
String MLG_Last_Modified_MDY = Main.dateFormat_MDY.format(Main.MLG_Last_Modified_Date);
String PROG_NAME = Main.PROG_NAME;
String VERSION = Main.VERSION;
String showHelpSTR = "";
String ReadMeText = "";
String VersionInfo = "";
//@formatter:off
ReadMeText = PROG_NAME + " version " + VERSION + newLine
+ newLine
+ "Updated " + MLG_Last_Modified_MDY + newLine
+ "(BuildID: " + Main.MLG_Last_Modified_Date.getTime() + ")" + newLine
+ newLine
+ "Original Code by Corrodias November 2010" + newLine
+ "Enhanced Code by Morlok8k Feb. 2011 to Now (or at least to " + MLG_Last_Modified_MDY + "!)" + newLine
+ "Additional Code by pr0f1x October 2011" + newLine
+ newLine
+ "Website: https://sites.google.com/site/minecraftlandgenerator/" + newLine
+ "Forum: http://www.minecraftforum.net/topic/187737-minecraft-land-generator/" + newLine
+ "Source: https://github.com/Morlok8k/MinecraftLandGenerator" + newLine
+ newLine
+ "-----------------------------------------------" + newLine
+ newLine
+ "This program lets you generate an area of land with your Minecraft Beta SMP server (and is prossibly future-proof for newer versions). You set up your java command line and minecraft server paths in the MinecraftLandGenerator.conf file, set up the server's server.properties file with the name of the world you wish to use, and then run this program." + newLine
+ "When a Minecraft server is launched, it automatically generates chunks within a square area of 25x25 chunks (400x400 blocks), centered on the current spawn point (formally 20x20 chunks, 320x320 blocks). When provided X and Z ranges as arguments, this program will launch the server repeatedly, editing the level.dat file between sessions, to generate large amounts of land without players having to explore them. The generated land will have about the X and Z ranges as requested by the arguments, though it will not be exact due to the spawn point typically not on the border of a chunk. (Because of this, MLG by default adds a slight overlap with each pass - 380x380 blocks) You can use the -x and -z switches to override the spawn offset and center the land generation on a different point." + newLine
+ "The program makes a backup of level.dat as level_backup.dat before editing, and restores the backup at the end. In the event that a level_backup.dat file already exists, the program will refuse to proceed, leaving the user to determine why the level_backup.dat file exists and whether they would rather restore it or delete it, which must be done manually." + newLine
+ newLine
+ "This program is public domain, and the source code is included in the .jar file. (If accidently missing, like in 1.3.0 and 1.4.0, it is always available at Github.)" + newLine
+ "The JNLP library is included (inside the .jar). It is not public domain. Its license is included, as LICENSE.TXT." + newLine
+ "It is also available at: http://jnbt.sourceforge.net/" + newLine
+ newLine
+ "The \"unescape\" method/function is also not Public Domain. Its License is the W3C\u00A9 Software License, and located here: http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231"
+ newLine
+ "Other Public Domain code has been used in this program, and references to sources are included in the comments of " + PROG_NAME + "'s source code."
+ newLine
+ "-----------------------------------------------" + newLine
+ newLine;
//@formatter:on
showHelpSTR = showHelp(false); //stored as a string for easier manipulation in the future
//@formatter:off
VersionInfo = newLine
+ "-----------------------------------------------" + newLine
+ newLine
+ "Version History:" + newLine
+ "Morlok8k:" + newLine
+ "1.7.0" + newLine
+ "- Major Code Optimization" + newLine
+ "- Drastically reduced the amount of time it takes for MLG to expand a world after it has already done so before!" + newLine
+ " (To do this, I needed to rewrite the Main loop of the program, and add my own Coordinate object)" + newLine
+ "- Added Resume Functionality" + newLine
+ "- Updated Time Output yet again." + newLine
+ "- Made xx% output nicer by rewriting previous existing line." + newLine
+ "- Misc. Tweaks" + newLine
+ "- Misc. Additions" + newLine
+ "1.6.3" + newLine
+ "- Minor Code Optimization" + newLine
+ "- Finely got on the ball and added the JNBT source and everything (as an internal .zip) to be completely faithful to his license" + newLine
+ "- Also adding script files internally in the .jar for archive (or offline) purposes. (Manual Extract needed for use)" + newLine
+ "- Modified output of MLG slightly to show whats the server and whats MLG. (I may do more with this later.)" + newLine
+ "1.6.2" + newLine
+ "- Major Code Optimization" + newLine
+ "- 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
+ "- Updated Time Output." + newLine
+ "- Changed estimated time remaining to count all runs, not just the last four." + newLine
+ "- Added the time it took to complete at the end of generation." + newLine
+ newLine
+ "1.6.1" + newLine
+ "- Added some modifications for scripting (Mainly for a new Initial setup script)" + newLine
+ "- Changed MLG's Y to Z. Now it matches Minecraft. Y in the game is Height." + newLine
+ "- Renamed -y switch to -z. MLG will remain backwards compatible if you use the old -y switch." + newLine
+ "- Updated -printspawn to show X,Y,Z" + newLine
+ "- Added End-of-Generation ASCII-Graphic" + newLine
+ "- Slightly altered some text output" + newLine
+ newLine
+ "1.6.05" + newLine
+ "- MLG displays if the server is converting the Map format, when not in verbose mode. (McRegion -> Anvil, or Chunk-File -> McRegion)" + newLine
+ "- Minor fixes/edits/typos" + newLine
+ "- Added link to new MLG website to readme file"
+ newLine
+ "1.6.03" + newLine
+ "- added decoding of escape characters of URL's (so a space is a \" \" and not \"%20\")" + newLine
+ "- added \"-downloadlist [list]\" where [list] is a text file with URL's on each line" + newLine
+ newLine
+ "1.6.02" + newLine
+ "- small fix on caculating md5sum where old version didnt pad out to 32chars with zeros on the left side"
+ "- quick Archive intergity fix after injecting source code into .jar after it compiled."
+ "- no new functionality, md5 issue doesnt affect -update on old versions."
+ newLine
+ "1.6.0" + newLine
+ "- NOW DOES NOT NEED ANY SCRIPT FILES!" + newLine
+ "- Added the ability to download files from the internet" + newLine
+ "- Added a switch to download any file off the internet, if needed (useless for most people, but included it in case I wanted it in the future.)" + newLine
+ "- Added the ability to check what version the .jar is. (Using MD5 hashes, timestamps, and the BuildID file)" + newLine
+ "- Added \"-update\" to download new versions of MLG directly from github." + newLine
+ "- Updated estimated time. Now shows up on loop 2+ instead of loop 4+." + newLine
+ "- Standard % output of the Server should look nicer now." + newLine
+ "- Code Refactoring" + newLine
+ "- Code Formatting" + newLine
+ "- Code Optimization" + newLine
+ "- Duplicate sections of code have been turned into Methods/\"Functions\"" + newLine
+ newLine
+ "1.5.1" + newLine
+ "- pr0f1x: Added the \"save-all\" command to be sent to the server before shutting it down." + newLine
+ "- pr0f1x: Added a 40 second wait before shutting down." + newLine
+ "- Morlok8k: Made 40 second wait optional." + newLine
+ "- Morlok8k: Changed the Dimensions code. (I had assumed it would be DIM-1, DIM-2, etc. but it turned out to be DIM-1 and DIM1. Change reflects Server output of \"Level n\")" + newLine
+ "- Morlok8k: Config file is automatically updated to reflect these changes." + newLine
+ "- Morlok8k: Cleaned up code." + newLine
+ newLine
+ "1.5.0" + newLine
+ "- Supports Server Beta 1.6.4 (& hopefully future versions as well, while remaining backward compatible.)" + newLine
+ "- Added \"-a\",\"-alt\" to use alternate method (a slightly simplier version of 1.3.0's code - pure verbose only)" + newLine
+ "- Added world specific output for 9 dimensions (DIM-1 is the Nether, DIM-2 through DIM-9 dont exist yet, but if and when they do, you can configure it's text). (\"Level 0\", the default world, is displayed as the worlds name)" + newLine
+ "- Updated Config File for these Dimensions." + newLine
+ "- Reads and outputs the Seed to the output. (If you had used text for the Seed, Minecraft converts it into a number. This outputs the number.)" + newLine
+ "- Changed the default 300 blocks to 380. The server now makes a 400x400 square block terrain instead of 320x320. Thus it is faster because there are less loops. To use the old way, use \"-i300\"" + newLine
+ "- Added total Percentage done (technically, it displays the % done once the server finishes...)" + newLine
+ "- Added debugging output vars of conf file (disabled - need to re-compile source to activate)" + newLine
+ newLine
+ "\t\t+ (the goal is to have MLG be configureable, so it can work on any version of the server, past or present.)" + newLine
+ newLine
+ "*** 1.4.5 (pre 1.5.0) ***" + newLine
+ "- sorry! I shouldn't release untested code..." + newLine
+ "*************************" + newLine
+ newLine
+ "1.4.4" + newLine
+ "- Added ablilty to ignore [WARNING] and [SEVERE] errors with \"-w\"" + newLine
+ newLine
+ "1.4.3" + newLine
+ "- Fixed \"-ps\",\"-printspawn\" as I had forgot I had broken it in 1.4.0 - due to config file change." + newLine
+ newLine
+ "1.4.2" + newLine
+ "- No New Features" + newLine
+ "- Changed non-verbose mode to display server progress on the same line, saving a lot of space." + newLine
+ " - This couldn't wait for 1.5.0 ... I (Morlok8k) liked it too much." + newLine
+ newLine
+ "1.4.0" + newLine
+ "- Future Proofing" + newLine
+ "- Configurble Server Message reading. (If server updates and breaks MLG, you can add the new text!)" + newLine
+ "- Updated config file, and auto updating from old format." + newLine
+ "- Added % of spawn area to non-verbose output." + newLine
+ "- Removed datetime stamps from server output in verbose mode" + newLine
+ "- Other Misc fixes." + newLine
+ newLine
+ "1.3.0" + newLine
+ "- Fixed Problems with Minecraft Beta 1.3 -- Morlok8k" + newLine
+ newLine
+ "-----------------------------------------------" + newLine
+ newLine
+ "Corrodias:" + newLine
+ "1.2.0" + newLine
+ "- land generation now centers on the spawn point instead of [0, 0]" + newLine
+ "- the server is launched once before the spawn point is changed, to verify that it can run and to create a world if one doesn't exist" + newLine
+ "- added -printspawn [-ps] switch to print the current spawn coordinates to the console" + newLine
+ "- added -x and -y switches to override the X and Y offsets" + newLine
+ "- added -v switch, does the same as -verbose" + newLine
+ "- improved status message spacing to make things easier to read" + newLine
+ "- improved time estimation algorithm: it now averages the last 3 launches" + newLine
+ newLine
+ "1.1.0" + newLine
+ "- added MinecraftLandGenerator.conf file to hold the java command line and the server path" + newLine
+ "- added -conf solo switch to generate a .conf file" + newLine
+ "- added -verbose switch to output server output to the console (default is to ignore it)" + newLine
+ "- added -i switch to allow customizing the block increment size (default is 300)" + newLine
+ "- added instructions output in this version, i think" + newLine
+ "- improved status message output to include current iteration and total iterations" + newLine
+ newLine
+ "1.0.0" + newLine
+ "- initial release" + newLine
+ newLine
+ "-----------------------------------------------" + newLine
+ newLine
+ "Notes:" + newLine
+ "Due to changes in server beta 1.6, it now generates the nether as well as the world at the same time." + newLine
+ "However, Since beta 1.9 and Minecraft 1.0, the nether or the end is no longer generated."
+ "I recommend using MCEDIT to relight the map after you generate it. This will take a long time, but should fix all those incorrectly dark spots in your level." + newLine;
//@formatter:on
MLG_FileWrite.writeTxtFile(readmeFile, ReadMeText + showHelpSTR + VersionInfo);
}
/**
* Displays or returns Help information
*
* @param SysOut
* <br>
* Set TRUE to display info to System.out. (Returns null) <br>
* Set FALSE to return info as String.
* @author Morlok8k
*/
public static String showHelp(boolean SysOut) {
String Str = null;
String NewLine = newLine;
if (SysOut) {
NewLine = NewLine + Main.MLG;
}
MLGFileNameShort = Main.MLGFileNameShort;
MinecraftLandGeneratorConf = Main.MinecraftLandGeneratorConf;
defaultReadmeFile = Main.defaultReadmeFile;
//@formatter:off
Str = "Usage: java -jar " + MLGFileNameShort + " x z [serverpath] [switches]" + NewLine
+ NewLine
+ "Arguments:" + NewLine
+ " x : X range to generate" + NewLine
+ " z : Z range to generate" + NewLine
+ " serverpath : the path to the directory in which the server runs (takes precedence over the config file setting)" + NewLine
+ NewLine
+ "Switches:" + NewLine
+ " -verbose : causes the application to output the server's messages to the console" + NewLine
+ " -v : same as -verbose" + NewLine
+ " -w : Ignore [WARNING] and [SEVERE] messages." + NewLine
+ " -alt : alternate server launch sequence" + NewLine
+ " -a : same as -alt" + NewLine
+ " -nowait : don't pause for anything" + NewLine
+ " -n : same as -nowait" + NewLine
+ " -i# : override the iteration spawn offset increment (default 380) (example: -i100)" + NewLine
+ " -x# : set the X offset to generate land around (example: -x0 or -x1000 or -x-500)" + NewLine
+ " -z# : set the Z offset to generate land around (example: -z0 or -z1000 or -z-500)" + NewLine
+ NewLine
+ "Other options:" + NewLine
+ " java -jar " + MLGFileNameShort + " -update" + NewLine
+ " Checks for and downloads new versions of MLG online." + NewLine
+ NewLine
+ " java -jar " + MLGFileNameShort + " -printspawn" + NewLine
+ " java -jar " + MLGFileNameShort + " -ps" + NewLine
+ " Outputs the current world's spawn point coordinates." + NewLine
+ NewLine
+ " java -jar " + MLGFileNameShort + " -conf" + NewLine
+ " java -jar " + MLGFileNameShort + " -conf download" + NewLine
+ " Generates or downloads a "+ MinecraftLandGeneratorConf + " file." + NewLine
+ NewLine
+ " java -jar " + MLGFileNameShort + " -readme readme.txt" + NewLine
+ " java -jar " + MLGFileNameShort + " -readme" + NewLine
+ " Generates a readme file using supplied name or the default " + defaultReadmeFile + NewLine
+ NewLine
+ " java -jar " + MLGFileNameShort + " -downloadfile http://example.com/file.txt" + NewLine
+ " Downloads whatever file from the internet you give it." + NewLine
+ " java -jar " + MLGFileNameShort + " -downloadlist list.txt" + NewLine
+ " list.txt (or any other file) contains a URL on each line which will be downloaded." + NewLine
+ NewLine
+ " java -jar " + MLGFileNameShort + " -version" + NewLine
+ " java -jar " + MLGFileNameShort + " -help" + NewLine
+ " java -jar " + MLGFileNameShort + " /?" + NewLine
+ " Prints this message." + NewLine
+ NewLine
+ "When launched with the -conf switch, this application creates a " + MinecraftLandGeneratorConf + " file that contains configuration options." + NewLine
+ "If this file does not exist or does not contain all required properties, the application will not run." + NewLine
+ NewLine
+ MinecraftLandGeneratorConf + " properties:" + NewLine
+ " Java : The command line to use to launch the server" + NewLine
+ " ServerPath : The path to the directory in which the server runs (can be overridden by the serverpath argument)" + NewLine
+ " Done_Text : The output from the server that tells us that we are done" + NewLine
+ " Preparing_Text : The output from the server that tells us the percentage" + NewLine
+ "Preparing_Level : The output from the server that tells us the level it is working on" + NewLine
+ " Level-0 : Name of Level 0: The Overworld" + NewLine
+ " Level-1 : Name of Level 1: The Nether" + NewLine
+ " Level-2 : Name of Level 2: The End" + NewLine
+ " Level-3 : Name of Level 3: (Future Level)" + NewLine
+ " Level-4 : Name of Level 4: (Future Level)" + NewLine
+ " Level-5 : Name of Level 5: (Future Level)" + NewLine
+ " Level-6 : Name of Level 6: (Future Level)" + NewLine
+ " Level-7 : Name of Level 7: (Future Level)" + NewLine
+ " Level-8 : Name of Level 8: (Future Level)" + NewLine
+ " Level-9 : Name of Level 9: (Future Level)" + NewLine
+ " WaitSave : Optional: Wait before saving." + NewLine;
//@formatter:on
String returnString = null;
if (SysOut) {
Main.out(Str);
Main.out("");
} else {
returnString = Str;
}
return returnString;
}
}

View File

@ -30,8 +30,8 @@ public class Unescape {
*/ */
public static String unescape(final String s) { public static String unescape(final String s) {
StringBuffer sbuf = new StringBuffer(); final StringBuffer sbuf = new StringBuffer();
int l = s.length(); final int l = s.length();
int ch = -1; int ch = -1;
int b, sumb = 0; int b, sumb = 0;
for (int i = 0, more = -1; i < l; i++) { for (int i = 0, more = -1; i < l; i++) {
@ -39,13 +39,13 @@ public class Unescape {
switch (ch = s.charAt(i)) { switch (ch = s.charAt(i)) {
case '%': case '%':
ch = s.charAt(++i); ch = s.charAt(++i);
int hb = final int hb =
(Character.isDigit((char) ch) ? ch - '0' : 10 + Character (Character.isDigit((char) ch) ? ch - '0' : (10 + Character
.toLowerCase((char) ch) - 'a') & 0xF; .toLowerCase((char) ch)) - 'a') & 0xF;
ch = s.charAt(++i); ch = s.charAt(++i);
int lb = final int lb =
(Character.isDigit((char) ch) ? ch - '0' : 10 + Character (Character.isDigit((char) ch) ? ch - '0' : (10 + Character
.toLowerCase((char) ch) - 'a') & 0xF; .toLowerCase((char) ch)) - 'a') & 0xF;
b = (hb << 4) | lb; b = (hb << 4) | lb;
break; break;
case '+': case '+':
@ -57,7 +57,9 @@ public class Unescape {
/* Decode byte b as UTF-8, sumb collects incomplete chars */ /* Decode byte b as UTF-8, sumb collects incomplete chars */
if ((b & 0xc0) == 0x80) { // 10xxxxxx (continuation byte) if ((b & 0xc0) == 0x80) { // 10xxxxxx (continuation byte)
sumb = (sumb << 6) | (b & 0x3f); // Add 6 bits to sumb sumb = (sumb << 6) | (b & 0x3f); // Add 6 bits to sumb
if (--more == 0) sbuf.append((char) sumb); // Add char to sbuf if (--more == 0) {
sbuf.append((char) sumb); // Add char to sbuf
}
} else if ((b & 0x80) == 0x00) { // 0xxxxxxx (yields 7 bits) } else if ((b & 0x80) == 0x00) { // 0xxxxxxx (yields 7 bits)
sbuf.append((char) b); // Store in sbuf sbuf.append((char) b); // Store in sbuf
} else if ((b & 0xe0) == 0xc0) { // 110xxxxx (yields 5 bits) } else if ((b & 0xe0) == 0xc0) { // 110xxxxx (yields 5 bits)