package com.lifeknight.relaymcbungeemain.utilities; import java.util.ArrayList; import java.util.List; public class Version implements Comparable { private final List values = new ArrayList<>(); public Version(String representation) { for (String s : representation.split("\\.")) { this.values.add(Integer.parseInt(s)); } } public boolean isGreater(Version o) { return this.compareTo(o) > 0; } @Override public int compareTo(Version o) { int[] home = toPrimitive(this.values.toArray(new Integer[0])); int[] other = toPrimitive(o.values.toArray(new Integer[0])); for (int i = 0; i < home.length; i++) { int v = home[i]; if (other.length > i) { int v1 = other[i]; if (v > v1) { return 1; } else if (v < v1) { return -1; } } else { return 1; } } if (other.length > home.length) { return -1; } return 0; } private static int[] toPrimitive(Integer[] array) { if (array == null) { return null; } else if (array.length == 0) { return new int[0]; } else { int[] result = new int[array.length]; for(int i = 0; i < array.length; ++i) { result[i] = array[i]; } return result; } } }