-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerUtils.java
More file actions
66 lines (53 loc) · 1.86 KB
/
Copy pathServerUtils.java
File metadata and controls
66 lines (53 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package ru.cwcode.cwutils.server;
import ru.cwcode.cwutils.numbers.NumbersUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ServerUtils {
private static final Pattern pattern = Pattern.compile("([\\d.]+)");
private static final Map<String, Integer> weights = new HashMap<>();
public static int getVersionWeight(String version) {
if (weights.containsKey(version)) return weights.get(version);
Matcher matcher = pattern.matcher(version);
if (!matcher.find()) return 0;
String[] data = matcher.group(1).split("\\.");
int multiplier = 10000;
int intVersion = 0;
for (String num : data) {
if (!NumbersUtils.isInteger(num)) return 0;
intVersion += Integer.parseInt(num) * Math.max(multiplier, 1);
multiplier /= 100;
}
weights.put(version, intVersion);
return intVersion;
}
/**
* @deprecated <p> Используйте {@link PaperServerUtils#isVersionBefore1_16_5()}
*/
@Deprecated
public static boolean isVersionBefore1_16_5() {
return PaperServerUtils.isVersionBefore1_16_5();
}
/**
* @deprecated <p> Используйте {@link PaperServerUtils#isVersionBeforeOrEqual1_12_2()}
*/
@Deprecated
public static boolean isVersionBeforeOrEqual1_12_2() {
return PaperServerUtils.isVersionBeforeOrEqual1_12_2();
}
/**
* @deprecated <p> Используйте {@link PaperServerUtils#isVersionGreater_1_16_5()}
*/
@Deprecated
public static boolean isVersionGreater_1_16_5() {
return PaperServerUtils.isVersionGreater("1.16.5");
}
/**
* @deprecated <p> Используйте {@link PaperServerUtils#isVersionGreater(String)}
*/
@Deprecated
public static boolean isVersionGreater(String version) {
return PaperServerUtils.isVersionGreater(version);
}
}