Skip to content

Commit

Permalink
To hell with Apache Commons!
Browse files Browse the repository at this point in the history
  • Loading branch information
2008Choco committed Feb 11, 2024
1 parent 231f5bd commit 9bdca05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
import wtf.choco.veinminer.pattern.VeinMiningPatternDefault;
import wtf.choco.veinminer.pattern.VeinMiningPatternStaircase;
import wtf.choco.veinminer.pattern.VeinMiningPatternStaircase.Direction;
import wtf.choco.veinminer.player.VeinMinerPlayerManager;
import wtf.choco.veinminer.pattern.VeinMiningPatternTunnel;
import wtf.choco.veinminer.player.VeinMinerPlayerManager;
import wtf.choco.veinminer.tool.ToolCategoryRegistry;
import wtf.choco.veinminer.update.SpigotMCUpdateChecker;
import wtf.choco.veinminer.update.StandardVersionSchemes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang.math.NumberUtils;

/**
* A utility class holding constants representing standard version schemes.
*/
Expand All @@ -17,7 +15,7 @@ public final class StandardVersionSchemes {
String[] firstSplit = splitVersionInfo(first), secondSplit = splitVersionInfo(second);

for (int i = 0; i < Math.min(firstSplit.length, secondSplit.length); i++) {
int currentValue = NumberUtils.toInt(firstSplit[i], -1), newestValue = NumberUtils.toInt(secondSplit[i], -1);
int currentValue = toInt(firstSplit[i], -1), newestValue = toInt(secondSplit[i], -1);

if (newestValue > currentValue) {
return second;
Expand All @@ -43,4 +41,16 @@ private static String[] splitVersionInfo(String version) {
return matcher.group().split("\\.");
}

private static int toInt(String string, int defaultValue) {
if (string == null) {
return defaultValue;
}

try {
return Integer.parseInt(string);
} catch (NumberFormatException e) {
return defaultValue;
}
}

}

0 comments on commit 9bdca05

Please sign in to comment.