Skip to content

Commit c7b38f1

Browse files
committed
fix(Tools/mcVersiontoInt): Fix edgecase for versions like 1.21
1 parent bc5034f commit c7b38f1

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

  • app_pojavlauncher/src/main/java/net/kdt/pojavlaunch

app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,11 +1537,16 @@ public static Integer mcVersiontoInt(String mcVersion){
15371537
String[] iVersionArray = new String[3];
15381538
// Make sure this is actually a version string
15391539
for (int i = 0; i < iVersionArray.length; i++) {
1540-
// Ensure there's padding
1541-
sVersionArray[i] = String.format("%3s", sVersionArray[i]).replace(' ', '0');
1542-
System.out.println(sVersionArray[i]);
1543-
// Grab only the last 3, MCJE 999.999.999 isnt coming soon anyway
1544-
sVersionArray[i] = sVersionArray[i].substring(sVersionArray[i].length() - 3);
1540+
try {
1541+
// Ensure there's padding
1542+
sVersionArray[i] = String.format("%3s", sVersionArray[i]).replace(' ', '0');
1543+
// Grab only the last 3, MCJE 999.999.999 isnt coming soon anyway
1544+
sVersionArray[i] = sVersionArray[i].substring(sVersionArray[i].length() - 3);
1545+
} catch (ArrayIndexOutOfBoundsException ignored){
1546+
// If we don't get 3 a third array, pad with 0s because it's probably 1.21 or something
1547+
iVersionArray[i] = "000";
1548+
continue;
1549+
}
15451550
try {
15461551
// Verify its a real deal, legit number
15471552
Integer.parseInt(sVersionArray[i]);

0 commit comments

Comments
 (0)