package prospector.shootingstar.version;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class VersionUtils {
    public static boolean isVersionLessOrEqual(Version comparate1, Version comparate2) {
        if (comparate1.major > comparate2.major) {
            return false;
        } else if (comparate1.major == comparate2.major) {
            if (comparate1.minor > comparate2.minor) {
                return false;
            } else if (comparate1.major == comparate2.major && comparate1.minor == comparate2.minor) {
                if (comparate1.patch > comparate2.patch) {
                    return false;
                }
            }
            return true;
        }
        return true;
    }

    public static Version getVersion(String version) {
        if (version.matches("(\\d+\\.\\d+\\.+\\d-\\d+\\.\\d+\\.\\d+-\\d)")) {
            Pattern pattern = Pattern.compile("-(\\d+)\\.(\\d+)\\.(\\d+)-");
            Matcher matcher = pattern.matcher(version);
            return new Version(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3)));
        }
        return new Version(1, 0, 0);
    }
}

@@ -39,73 +39,8 @@
 n;%0A%0A
-import java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0A%0A
 publ
@@ -666,467 +666,7 @@
    %7D
-%0A%0A    public static Version getVersion(String version) %7B%0A        if (version.matches(%22(%5C%5Cd+%5C%5C.%5C%5Cd+%5C%5C.+%5C%5Cd-%5C%5Cd+%5C%5C.%5C%5Cd+%5C%5C.%5C%5Cd+-%5C%5Cd)%22)) %7B%0A            Pattern pattern = Pattern.compile(%22-(%5C%5Cd+)%5C%5C.(%5C%5Cd+)%5C%5C.(%5C%5Cd+)-%22);%0A            Matcher matcher = pattern.matcher(version);%0A            return new Version(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3)));%0A        %7D%0A        return new Version(1, 0, 0);%0A    %7D
 %0A%7D%0A

Improve version stuff