Skip to content

Commit 73596f4

Browse files
committed
prepare for the new version system
1 parent fc00fb8 commit 73596f4

File tree

1 file changed

+15
-3
lines changed
  • spigot/common/src/main/java/io/github/projectunified/blockutil/spigot/common

1 file changed

+15
-3
lines changed

spigot/common/src/main/java/io/github/projectunified/blockutil/spigot/common/Version.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,27 @@
99
public class Version {
1010
private static final int MAJOR_VERSION;
1111
private static final int MINOR_VERSION;
12+
private static final int PATCH_VERSION;
1213

1314
static {
14-
Matcher versionMatcher = Pattern.compile("MC: \\d\\.(\\d+)(\\.(\\d+))?").matcher(Bukkit.getVersion());
15+
Matcher versionMatcher = Pattern.compile("MC: (\\d+)\\.(\\d+)(\\.(\\d+))?").matcher(Bukkit.getVersion());
1516
if (versionMatcher.find()) {
16-
MAJOR_VERSION = Integer.parseInt(versionMatcher.group(1));
17-
MINOR_VERSION = Optional.ofNullable(versionMatcher.group(3)).filter(s -> !s.isEmpty()).map(Integer::parseInt).orElse(0);
17+
int majorVersion = Integer.parseInt(versionMatcher.group(1));
18+
int minorVersion = Integer.parseInt(versionMatcher.group(2));
19+
int patchVersion = Optional.ofNullable(versionMatcher.group(4)).filter(s -> !s.isEmpty()).map(Integer::parseInt).orElse(0);
20+
if (majorVersion == 1) {
21+
MAJOR_VERSION = minorVersion;
22+
MINOR_VERSION = patchVersion;
23+
PATCH_VERSION = 0;
24+
} else {
25+
MAJOR_VERSION = majorVersion;
26+
MINOR_VERSION = minorVersion;
27+
PATCH_VERSION = patchVersion;
28+
}
1829
} else {
1930
MAJOR_VERSION = -1;
2031
MINOR_VERSION = -1;
32+
PATCH_VERSION = -1;
2133
}
2234
}
2335

0 commit comments

Comments
 (0)