diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/Main.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/Main.java index 49ca9f4..cb32853 100644 --- a/src/main/java/io/github/meeples10/mcresourceanalyzer/Main.java +++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/Main.java @@ -61,14 +61,13 @@ public static void main(String[] args) { } catch(IOException e) { e.printStackTrace(); } - Main.println("Save statistics: " + saveStatistics + "\nGenerate HTML table: " + generateTable - + (generateTable - ? ("\nTable template: " + (tableTemplatePath.equals("") ? "(none)" : tableTemplatePath)) - : "") - + "\nRegion version: " + selectedVersion + "\nModernize block IDs: " + modernizeIDs + "\nBlock IDs: " - + BLOCK_NAMES.size() + "\nBlock IDs to merge: " + BLOCKS_TO_MERGE.size() + "\nInput: " - + inputFile.getPath() + "\nOutput prefix: " + (outputPrefix.equals("") ? "(default)" : outputPrefix) - + "\n--------------------------------"); + Main.printf("Save statistics: %b\nGenerate HTML table: %b%s\nRegion version: %s\nModernize block IDs: %b" + + "\nBlock IDs: %d\nBlock IDs to merge: %d\nInput: %s\nOutput prefix: %s\n--------------------------------\n", + saveStatistics, generateTable, + (generateTable ? ("\nTable template: " + (tableTemplatePath.equals("") ? "(none)" : tableTemplatePath)) + : ""), + selectedVersion, modernizeIDs, BLOCK_NAMES.size(), BLOCKS_TO_MERGE.size(), inputFile.getPath(), + (outputPrefix.equals("") ? "(default)" : outputPrefix)); RegionAnalyzer analyzer; try { analyzer = selectedVersion.getAnalyzerInstance(); @@ -85,7 +84,7 @@ public static void main(String[] args) { System.exit(1); } analyzer.run(inputFile); - Main.println("Completed after " + millisToHMS(System.currentTimeMillis() - analyzer.getStartTime())); + Main.printf("Completed after %s\n", millisToHMS(System.currentTimeMillis() - analyzer.getStartTime())); } private static CommandSpec createCommandSpec() { @@ -284,10 +283,6 @@ public static void print(Object s) { if(!silent) System.out.print(s); } - public static void println(Object s) { - if(!silent) System.out.println(s); - } - public static void printf(String format, Object... args) { if(!silent) System.out.printf(format, args); } diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzer.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzer.java index 74c4350..724342c 100644 --- a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzer.java +++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzer.java @@ -65,14 +65,15 @@ public void run(File input) { } duration = System.currentTimeMillis() - getStartTime(); - Main.println("Completed analysis in " + Main.millisToHMS(duration)); + Main.printf("Completed analysis in %s\n", Main.millisToHMS(duration)); long totalBlocks = 0L; for(String key : blockCounter.keySet()) { totalBlocks += blockCounter.get(key); } - Main.println("--------------------------------\n" + blockCounter.size() + " unique blocks\n" + totalBlocks - + " blocks total\n--------------------------------"); + Main.printf( + "--------------------------------\n%d unique blocks\n%d blocks total\n--------------------------------\n", + blockCounter.size(), totalBlocks); Main.print("Sorting data... "); heightCounter = heightCounter.entrySet().stream().sorted(Map.Entry.comparingByKey(new Comparator() { @@ -81,7 +82,7 @@ public int compare(String arg0, String arg1) { return Long.compare(blockCounter.get(arg1), blockCounter.get(arg0)); } })).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); - Main.println("Done"); + Main.print("Done\n"); double totalExcludingAir = (double) (totalBlocks - (blockCounter.containsKey("0") ? blockCounter.get("0") : 0) - (blockCounter.containsKey("minecraft:air") ? blockCounter.get("minecraft:air") : 0) @@ -119,11 +120,11 @@ public int compare(String arg0, String arg1) { } data.append("\n"); } - Main.println("Done"); + Main.print("Done\n"); try { File out = new File(Main.getOutputPrefix() + ".csv"); Main.writeStringToFile(out, data.toString()); - Main.println("CSV written to " + out.getAbsolutePath()); + Main.printf("CSV written to %s\n", out.getAbsolutePath()); } catch(IOException e) { e.printStackTrace(); System.exit(1); @@ -132,7 +133,7 @@ public int compare(String arg0, String arg1) { try { File out = new File(Main.getOutputPrefix() + ".html"); Main.writeStringToFile(out, generateTable((double) totalBlocks, totalExcludingAir)); - Main.println("\nTable written to " + out.getAbsolutePath()); + Main.printf("\nTable written to %s\n", out.getAbsolutePath()); } catch(IOException e) { e.printStackTrace(); System.exit(1); diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAlpha.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAlpha.java index bfba1da..55e3c72 100644 --- a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAlpha.java +++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAlpha.java @@ -31,7 +31,7 @@ public void findChunks(File world) { System.err.println("Error: World directory is empty"); System.exit(1); } - Main.println(chunkFiles.size() + " chunks found"); + Main.printf("%d chunks found\n", chunkFiles.size()); } @Override diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerIndev.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerIndev.java index 2ff26b7..c5e8cbd 100644 --- a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerIndev.java +++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerIndev.java @@ -45,7 +45,7 @@ public void findChunks(File world) { public void analyze() { Analysis a = analyzeWorld(blocks, data, width, height); duration = System.currentTimeMillis() - getStartTime(); - Main.println(("Completed analysis in " + Main.millisToHMS(duration))); + Main.printf("Completed analysis in %d\n", Main.millisToHMS(duration)); blockCounter.putAll(a.blocks); heightCounter.putAll(a.heights); }