diff --git a/src/main/java/org/auioc/mcmod/arnicalib/base/version/HVersion.java b/src/main/java/org/auioc/mcmod/arnicalib/base/version/HVersion.java index 3db54efe..7bda226b 100644 --- a/src/main/java/org/auioc/mcmod/arnicalib/base/version/HVersion.java +++ b/src/main/java/org/auioc/mcmod/arnicalib/base/version/HVersion.java @@ -14,15 +14,6 @@ public class HVersion { public final boolean isDirty; public final boolean isDev; - public HVersion(String main, String full) { - this.main = main; - this.full = full; - this.revisionHash = getRevisionHash(full); - this.buildNumber = getBuildNumber(full); - this.isDev = full.contains("-dev-"); - this.isDirty = full.contains("-dirty"); - } - public HVersion(String main, String full, String revisionHash, int buildNumber, boolean isDirty, boolean isDev) { this.main = main; this.full = full; @@ -32,16 +23,28 @@ public HVersion(String main, String full, String revisionHash, int buildNumber, this.isDev = isDev; } + public HVersion(String main, String full) { + this( + main, full, + getRevisionHash(full), + getBuildNumber(full), + full.contains("-dirty"), + full.contains("-dev-") + ); + } + @Override public boolean equals(Object obj) { if (this == obj) return true; - if (obj instanceof HVersion other) return main.equals(other.main) && full.equals(other.full); + if (obj instanceof HVersion other) { + return this.main.equals(other.main) && this.full.equals(other.full); + } return false; } @Override public int hashCode() { - return main.hashCode() + full.hashCode(); + return 31 * this.main.hashCode() + this.full.hashCode(); } // ====================================================================== // @@ -49,10 +52,9 @@ public int hashCode() { private static final Pattern PATTERN_REVISION_HASH = Pattern.compile("(?<=rev\\.)[0-9a-fA-F]{7}"); private static final Pattern PATTERN_BUILD_NUMBER = Pattern.compile("(?<=build\\.)\\d+"); - private static String getRevisionHash(String fullVersion) { Matcher matcher = PATTERN_REVISION_HASH.matcher(fullVersion); - return (matcher.find()) ? matcher.group() : ""; + return (matcher.find()) ? matcher.group().toLowerCase() : ""; } private static int getBuildNumber(String fullVersion) {