diff --git a/README.md b/README.md index e205cfb..cb7dd49 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ java -jar mc-resource-analyzer-x.x.x.jar [-hHmsStV] [-B=PATH] [-M=PATH] [-o=STRI - `-s`, `--statistics`: Outputs a file with statistics about the analysis. - `-o`, `--output-prefix`: Use this argument to add a prefix to the program's output files. For example, using `-o abc` would result in the files `abc.csv` and `abc_table.html`. - `-v`, `--version-select`: Use this argument if you want to analyze a world that was not generated with the latest version of Minecraft. Selecting a version that does not match the version with which the regions were generated may result in unexpected behavior. The following versions are supported: - - `ANVIL_118` for 1.18 + - `ANVIL_118` for 1.18 to 1.20 - `ANVIL_2021` for 1.16 to 1.17 - `ANVIL_2018` for 1.13 to 1.15 - `ANVIL_2012` for 1.2 to 1.12 @@ -46,7 +46,7 @@ java -jar mc-resource-analyzer-x.x.x.jar [-hHmsStV] [-B=PATH] [-M=PATH] [-o=STRI ### Version compatibility -MCResourceAnalyzer 1.1.7 can analyze worlds generated with any version of Minecraft: Java Edition between Indev 0.31 20100122 and 1.18. +MCResourceAnalyzer 1.2.0 can analyze worlds generated with any version of Minecraft: Java Edition between Indev 0.31 20100122 and 1.20. Note that Indev worlds with the `Long` and `Deep` world shapes are not supported. diff --git a/pom.xml b/pom.xml index 3ca0161..7f43e3e 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,23 @@ io.github.meeples10.mcresourceanalyzer mc-resource-analyzer - 1.2.0-SNAPSHOT + 1.2.0 jar + MCResourceAnalyzer + https://github.com/Meeples10/MCResourceAnalyzer + Analyze Minecraft region files to determine the empirical distribution of block types. + + + BSD-3-Clause + https://spdx.org/licenses/BSD-3-Clause.html + + + UTF-8 + ${maven.build.timestamp} + yyyy-MM-dd @@ -19,6 +31,12 @@ + + + src/main/resources + true + + org.apache.maven.plugins diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/Main.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/Main.java index 95d1c44..b0d80d9 100644 --- a/src/main/java/io/github/meeples10/mcresourceanalyzer/Main.java +++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/Main.java @@ -9,9 +9,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.file.Files; -import java.text.DateFormat; import java.text.DecimalFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -19,13 +17,13 @@ import java.util.concurrent.TimeUnit; import picocli.CommandLine; +import picocli.CommandLine.IVersionProvider; import picocli.CommandLine.Model.CommandSpec; import picocli.CommandLine.Model.OptionSpec; import picocli.CommandLine.Model.PositionalParamSpec; import picocli.CommandLine.ParseResult; public class Main { - public static final DateFormat DATE_FORMAT = new SimpleDateFormat("dd MMM yyyy 'at' hh:mm:ss a zzz"); public static final FilenameFilter DS_STORE_FILTER = new FilenameFilter() { @Override public boolean accept(File dir, String name) { @@ -55,6 +53,7 @@ public static void main(String[] args) { if(commandLine.getCommandName().equals("
")) commandLine.setCommandName("java -jar mc-resource-analyzer-x.x.x.jar"); if(commandLine.isUsageHelpRequested()) commandLine.usage(System.out); + if(commandLine.isVersionHelpRequested()) commandLine.printVersionHelp(System.out); if(exitCode != 0 || commandLine.isUsageHelpRequested() || commandLine.isVersionHelpRequested()) System.exit(exitCode); try { @@ -93,7 +92,15 @@ public static void main(String[] args) { private static CommandSpec createCommandSpec() { CommandSpec spec = CommandSpec.create(); - spec.mixinStandardHelpOptions(true); + spec.mixinStandardHelpOptions(true).versionProvider(new IVersionProvider() { + @Override + public String[] getVersion() throws Exception { + List lines = readLines(Main.class.getResourceAsStream("/version.properties")); + return new String[] { + String.format("@|white,bold %s %s|@ @|faint %s|@", lines.get(0), lines.get(1), lines.get(2)), + String.format("@|yellow %s|@", lines.get(3)) }; + } + }); spec.addOption( OptionSpec.builder("-v", "--version-select").paramLabel("VERSION").type(RegionAnalyzer.Version.class) .description("Selects the version with which the region files were generated.").build()); @@ -202,7 +209,6 @@ public static int[] unstream(int bitsPerValue, int wordSize, boolean slack, long for(int i = 0; i < data.length; i++) { for(int n = 0; n < wordSize; n++) { int bit = (int) ((data[i] >> n) & 0x01); - // v = (v << 1) | bit; v = (bit << bl) | v; bl++; if(bl >= bitsPerValue) { @@ -251,14 +257,15 @@ private static void loadBlockNames() throws IOException { for(String line : readLines(Main.class.getResourceAsStream("/blocks.properties"))) { if(line.length() == 0) continue; String[] split = line.split("=", 2); - BLOCK_NAMES.put(split[0], split[1]); + if(!BLOCK_NAMES.containsKey(split[0])) BLOCK_NAMES.put(split[0], split[1]); } } private static void loadBlocksToMerge() throws IOException { for(String line : readLines(Main.class.getResourceAsStream("/merge.properties"))) { if(line.length() == 0) continue; - BLOCKS_TO_MERGE.add(Integer.valueOf(line.trim())); + int i = Integer.valueOf(line.trim()); + if(!BLOCKS_TO_MERGE.contains(i)) BLOCKS_TO_MERGE.add(i); } } diff --git a/src/main/resources/version.properties b/src/main/resources/version.properties new file mode 100644 index 0000000..d5c9f6b --- /dev/null +++ b/src/main/resources/version.properties @@ -0,0 +1,4 @@ +${project.name} +${project.version} +${timestamp} +${project.url}