diff --git a/tools/mapmerge/MapMerge.jar b/tools/mapmerge/MapMerge.jar index d1e515cfcd5..e0bd47ea836 100644 Binary files a/tools/mapmerge/MapMerge.jar and b/tools/mapmerge/MapMerge.jar differ diff --git a/tools/mapmerge/Run Map Merge.bat b/tools/mapmerge/Run Map Merge.bat index 2793b28a6b5..1c159f79ca2 100644 --- a/tools/mapmerge/Run Map Merge.bat +++ b/tools/mapmerge/Run Map Merge.bat @@ -1,5 +1,5 @@ @echo off -java -jar ../../tools/mapmerge/MapMerge.jar +java -jar MapMerge.jar ../../_maps/ pause \ No newline at end of file diff --git a/tools/mapmerge/Source/bin/MapMergerMain.class b/tools/mapmerge/Source/bin/MapMergerMain.class index 6396bbc7a72..c0ec043c239 100644 Binary files a/tools/mapmerge/Source/bin/MapMergerMain.class and b/tools/mapmerge/Source/bin/MapMergerMain.class differ diff --git a/tools/mapmerge/Source/src/MapMergerMain.java b/tools/mapmerge/Source/src/MapMergerMain.java index a85810a654a..873ae69cd84 100644 --- a/tools/mapmerge/Source/src/MapMergerMain.java +++ b/tools/mapmerge/Source/src/MapMergerMain.java @@ -9,70 +9,87 @@ public class MapMergerMain { private static Scanner input = new Scanner(System.in); - public static void main(String[] args) throws IOException{ - - System.out.print("Path to maps folder: "); - Path pathToMaps = Paths.get(input.nextLine()); + public static void main(String[] mapPath) throws IOException{ + Path pathToMaps = Paths.get(mapPath[0]); FileFinder dmmFinder = new FileFinder("*.dmm"); Files.walkFileTree(pathToMaps, dmmFinder); ArrayList foundFiles = dmmFinder.foundPaths; if (foundFiles.size() > 0) { - + try{ + merge(foundFiles); + }catch(Exception e){ + System.out.println("Something went wrong."); + e.printStackTrace(); + } + }else{ + System.out.println("No files were found in provided directory!"); + System.out.print("Path to maps folder: "); + pathToMaps = Paths.get(input.nextLine()); + dmmFinder = new FileFinder("*.dmm"); + Files.walkFileTree(pathToMaps, dmmFinder); + foundFiles = dmmFinder.foundPaths; + try{ + merge(foundFiles); + }catch(Exception e){ + System.out.println("Something went wrong."); + e.printStackTrace(); + } + } + } + + + public static void merge(ArrayList foundFiles){ - System.out.println("How many files do you want to merge?"); - int selection1; + System.out.println("How many files do you want to merge?"); + int selection1; + inputCheck:while(true){ + while(!input.hasNextInt()){ + String temp = input.next(); + System.out.println(temp + " is not a valid int."); + } + selection1 = input.nextInt(); + if(selection1 < 0){ + System.out.println("Use a number greater than 0!"); + continue inputCheck; + }else{ + break inputCheck; + } + } + + for(int numOfFiles = selection1; numOfFiles != 0; numOfFiles--){ + + for(int num = 0;num < foundFiles.size();num++){ + System.out.println(num + ": " + foundFiles.get(num)); + } + + System.out.print("File to use: "); + int selection2; inputCheck:while(true){ while(!input.hasNextInt()){ String temp = input.next(); System.out.println(temp + " is not a valid int."); } - selection1 = input.nextInt(); - if(selection1 < 0){ + selection2 = input.nextInt(); + if(selection2 < 0 || selection2 >= foundFiles.size()){ + if(selection2 < 0){ System.out.println("Use a number greater than 0!"); + }else{ + System.out.println("Use a number less than " + foundFiles.size() +"!"); + } continue inputCheck; }else{ break inputCheck; } } - for(int numOfFiles = selection1; numOfFiles != 0; numOfFiles--){ - - for(int num = 0;num < foundFiles.size();num++){ - System.out.println(num + ": " + foundFiles.get(num)); - } - - System.out.print("File to use: "); - int selection2; - inputCheck:while(true){ - while(!input.hasNextInt()){ - String temp = input.next(); - System.out.println(temp + " is not a valid int."); - } - selection2 = input.nextInt(); - if(selection2 < 0 || selection2 >= foundFiles.size()){ - if(selection2 < 0){ - System.out.println("Use a number greater than 0!"); - }else{ - System.out.println("Use a number less than " + foundFiles.size() +"!"); - } - continue inputCheck; - }else{ - break inputCheck; - } - } - - String newMap = foundFiles.get(selection2) + ""; - String oldMap = foundFiles.get(selection2) + ".backup"; - String[] passInto = new String[4]; - passInto[0] = "-clean"; - passInto[1] = oldMap; - passInto[2] = newMap; - passInto[3] = newMap; - MapPatcher.main(passInto); - } - - }else{ - System.out.println("No files were found!"); + String newMap = foundFiles.get(selection2) + ""; + String oldMap = foundFiles.get(selection2) + ".backup"; + String[] passInto = new String[4]; + passInto[0] = "-clean"; + passInto[1] = oldMap; + passInto[2] = newMap; + passInto[3] = newMap; + MapPatcher.main(passInto); } }