-
Notifications
You must be signed in to change notification settings - Fork 61
/
VersionChecker.java
48 lines (29 loc) · 1.4 KB
/
VersionChecker.java
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
package com.magmaguy.elitemobs.utils;
import org.bukkit.Bukkit;
public class VersionChecker {
public static boolean currentVersionIsUnder(int version, int subVersion) {
if (Bukkit.getBukkitVersion().split("[.]").length < 4) {
try {
return Integer.parseInt(Bukkit.getBukkitVersion().split("[.]")[1].substring(0, 2)) < version;
} catch (Exception ex) {
return Integer.parseInt(Bukkit.getBukkitVersion().split("[.]")[1].substring(0, 1)) < version;
}
}
if (Integer.parseInt(Bukkit.getBukkitVersion().split("[.]")[1]) < version) return true;
if (Integer.parseInt(Bukkit.getBukkitVersion().split("[.]")[1]) == version) {
try {
byte actualSubversion = Byte.parseByte(Bukkit.getBukkitVersion().split("[.]")[2].substring(0, 1));
return actualSubversion < subVersion;
} catch (Exception e) {
try {
byte actualSubversion = Byte.parseByte(Bukkit.getBukkitVersion().split("[.]")[2].substring(0, 0));
return actualSubversion < subVersion;
} catch (Exception ex) {
Bukkit.getLogger().warning("[EliteMobs] Couldn't read version properly, report this to the developer!");
return false;
}
}
}
return false;
}
}