Skip to content

Commit 4d3fb87

Browse files
v.1.1.1 part 1
- Fixed a bug, where with version string that only have 2 steps like 1.21 it would throw an error
1 parent 2793dbb commit 4d3fb87

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/java/de/littleprogrammer/guiapi/GuiApi.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,23 @@ public void init() {
4949
String preTrdIndicator = plugin.getServer().getBukkitVersion().split("\\.")[2];
5050
String trdIndicator = preTrdIndicator.split("-")[0];
5151

52+
//If version is like 1.21 it threw an error
53+
try {
54+
Integer.parseInt(secIndicator);
55+
} catch (NumberFormatException e) {
56+
secIndicator = secIndicator.split("-")[0];
57+
}
58+
59+
//If version is like 1.21 there is no .0 in the input string, but it needs to be for the following method
60+
try {
61+
Integer.parseInt(preTrdIndicator);
62+
} catch (NumberFormatException e) {
63+
trdIndicator = "0";
64+
}
65+
66+
//1.20.x
5267
if (Integer.parseInt(secIndicator) == 20) {
68+
//1.20.2
5369
if (Integer.parseInt(trdIndicator) >= 2) {
5470
version = ServerVersion.POST_1_20_2;
5571
} else {

0 commit comments

Comments
 (0)