0.12.7 - Fix version comparator AGAIN

This commit is contained in:
AppleDash 2017-07-15 23:49:05 -04:00
parent 31d311c229
commit 9a00cddf24
7 changed files with 11 additions and 14 deletions

View File

@ -9,7 +9,7 @@
<version>0</version>
</parent>
<artifactId>SaneEconomyCore</artifactId>
<version>0.12.6-SNAPSHOT</version>
<version>0.12.7-SNAPSHOT</version>
<dependencies>
<dependency>

View File

@ -17,15 +17,7 @@ public class VersionComparer {
int[] firstParts = intifyParts(first);
int[] secondParts = intifyParts(second);
if (secondParts[0] > firstParts[0]) {
return true;
}
if (secondParts[1] > firstParts[1]) {
return true;
}
return secondParts[2] > firstParts[2];
return computeInt(secondParts) > computeInt(firstParts);
}
private static int[] intifyParts(String version) {
@ -33,4 +25,8 @@ public class VersionComparer {
return new int[] { Integer.valueOf(firstParts[0]), Integer.valueOf(firstParts[1]), Integer.valueOf(firstParts[2]) };
}
private static int computeInt(int[] parts) {
return (parts[0] * 1000000) + (parts[1] * 1000) + parts[2];
}
}

View File

@ -1,7 +1,7 @@
name: SaneEconomy
author: AppleDash
main: org.appledash.saneeconomy.SaneEconomy
version: 0.12.6
version: 0.12.7
load: STARTUP
softdepend: [Vault]
commands:

View File

@ -15,5 +15,6 @@ public class VersionComparerTest {
Assert.assertFalse(VersionComparer.isSemVerGreaterThan("2.0.0", "1.0.0"));
Assert.assertTrue(VersionComparer.isSemVerGreaterThan("0.1.0", "0.2.0"));
Assert.assertTrue(VersionComparer.isSemVerGreaterThan("1.0.0", "2.0.0"));
Assert.assertFalse(VersionComparer.isSemVerGreaterThan("0.12.6", "0.5.7"));
}
}

View File

@ -16,7 +16,7 @@
<dependency>
<groupId>org.appledash</groupId>
<artifactId>SaneEconomyCore</artifactId>
<version>0.12.6-SNAPSHOT</version>
<version>0.12.7-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@ -17,7 +17,7 @@
<dependency>
<groupId>org.appledash</groupId>
<artifactId>SaneEconomyCore</artifactId>
<version>0.12.6-SNAPSHOT</version>
<version>0.12.7-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@ -16,7 +16,7 @@
<dependency>
<groupId>org.appledash</groupId>
<artifactId>SaneEconomyCore</artifactId>
<version>0.12.6-SNAPSHOT</version>
<version>0.12.7-SNAPSHOT</version>
</dependency>
</dependencies>