2016-02-16 20:07:51 +01:00
|
|
|
package fr.pandacube.java.util;
|
|
|
|
|
2016-08-26 02:13:43 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.List;
|
|
|
|
|
2016-02-16 20:07:51 +01:00
|
|
|
public enum MinecraftVersion {
|
2016-06-17 17:19:10 +02:00
|
|
|
v1_7_2_to_1_7_5(4, "1.7.2-1.7.5"),
|
|
|
|
v1_7_6_to_1_7_10(5, "1.7.6-1.7.10"),
|
|
|
|
v1_8(47, "1.8.x"),
|
|
|
|
v1_9(107, "1.9"),
|
|
|
|
v1_9_1(108, "1.9.1"),
|
|
|
|
v1_9_2(109, "1.9.2"),
|
2016-07-04 16:57:23 +02:00
|
|
|
v1_9_3_to_1_9_4(110, "1.9.3-1.9.4"),
|
2016-11-23 00:59:13 +01:00
|
|
|
v1_10(210, "1.10.x"),
|
2016-12-31 17:54:59 +01:00
|
|
|
v1_11(315, "1.11"),
|
2017-06-08 01:38:10 +02:00
|
|
|
v1_11_1_to_1_11_2(316, "1.11.1-1.11.2"),
|
2017-08-08 23:33:02 +02:00
|
|
|
v1_12(335, "1.12"),
|
|
|
|
v1_12_1(338, "1.12.1");
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-02-16 20:07:51 +01:00
|
|
|
public final int versionNumber;
|
2016-06-02 18:10:47 +02:00
|
|
|
public final String versionDisplay;
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-06-17 17:19:10 +02:00
|
|
|
private MinecraftVersion(int v, String d) {
|
2016-02-16 20:07:51 +01:00
|
|
|
versionNumber = v;
|
2016-06-02 18:10:47 +02:00
|
|
|
versionDisplay = d;
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
|
|
|
@Override
|
2016-06-02 18:10:47 +02:00
|
|
|
public String toString() {
|
|
|
|
return versionDisplay;
|
2016-02-16 20:07:51 +01:00
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-02-16 20:07:51 +01:00
|
|
|
public static MinecraftVersion getVersion(int v) {
|
|
|
|
for (MinecraftVersion mcV : MinecraftVersion.values())
|
2016-07-14 14:22:23 +02:00
|
|
|
if (mcV.versionNumber == v) return mcV;
|
|
|
|
|
2016-02-16 20:07:51 +01:00
|
|
|
return null;
|
|
|
|
}
|
2016-08-26 02:13:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String displayOptimizedListOfVersions(List<MinecraftVersion> versions) {
|
|
|
|
return String.join(", ", getVersionsDisplayList(versions));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static final List<String> getVersionsDisplayList(List<MinecraftVersion> versions) {
|
|
|
|
versions = new ArrayList<>(new HashSet<>(versions));
|
|
|
|
versions.sort((a, b) -> Integer.compare(a.versionNumber, b.versionNumber));
|
|
|
|
|
|
|
|
List<String> ret = new ArrayList<>();
|
|
|
|
|
|
|
|
// grouping 1.7 versions
|
|
|
|
if (versions.contains(v1_7_2_to_1_7_5) && versions.contains(v1_7_6_to_1_7_10)) {
|
|
|
|
versions.remove(v1_7_2_to_1_7_5);
|
|
|
|
versions.remove(v1_7_6_to_1_7_10);
|
|
|
|
ret.add("1.7");
|
|
|
|
}
|
|
|
|
// grouping 1.8 versions
|
|
|
|
if (versions.contains(v1_8)) {
|
|
|
|
versions.remove(v1_8);
|
|
|
|
ret.add("1.8");
|
|
|
|
}
|
|
|
|
// grouping 1.9 versions
|
|
|
|
if (versions.contains(v1_9) && versions.contains(v1_9_1) && versions.contains(v1_9_2)
|
|
|
|
&& versions.contains(v1_9_3_to_1_9_4)) {
|
|
|
|
versions.remove(v1_9);
|
|
|
|
versions.remove(v1_9_1);
|
|
|
|
versions.remove(v1_9_2);
|
|
|
|
versions.remove(v1_9_3_to_1_9_4);
|
|
|
|
ret.add("1.9");
|
|
|
|
}
|
|
|
|
// grouping 1.10 versions
|
|
|
|
if (versions.contains(v1_10)) {
|
|
|
|
versions.remove(v1_10);
|
|
|
|
ret.add("1.10");
|
|
|
|
}
|
2017-01-12 20:11:13 +01:00
|
|
|
// grouping 1.11 versions
|
|
|
|
if (versions.contains(v1_11) && versions.contains(v1_11_1_to_1_11_2)) {
|
|
|
|
versions.remove(v1_11);
|
|
|
|
versions.remove(v1_11_1_to_1_11_2);
|
|
|
|
ret.add("1.11");
|
|
|
|
}
|
2017-06-08 01:38:10 +02:00
|
|
|
// grouping 1.12 versions
|
2017-08-08 23:33:02 +02:00
|
|
|
if (versions.contains(v1_12) && versions.contains(v1_12_1)) {
|
2017-06-08 01:38:10 +02:00
|
|
|
versions.remove(v1_12);
|
2017-08-08 23:33:02 +02:00
|
|
|
versions.remove(v1_12_1);
|
2017-06-08 01:38:10 +02:00
|
|
|
ret.add("1.12");
|
|
|
|
}
|
2016-08-26 02:13:43 +02:00
|
|
|
|
|
|
|
for (MinecraftVersion v : versions)
|
|
|
|
ret.add(v.versionDisplay);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
2016-07-14 14:22:23 +02:00
|
|
|
|
2016-02-16 20:07:51 +01:00
|
|
|
}
|