diff --git a/Towny/src/main/java/com/palmergames/util/MathUtil.java b/Towny/src/main/java/com/palmergames/util/MathUtil.java index 644f1a187e..fa823ce057 100644 --- a/Towny/src/main/java/com/palmergames/util/MathUtil.java +++ b/Towny/src/main/java/com/palmergames/util/MathUtil.java @@ -69,6 +69,7 @@ public static double getDoubleOrThrow(String input) throws TownyException { } public static int getIntOrThrow(String input) throws TownyException { + input = parseAbbreviations(input); int i; try { i = Integer.parseInt(input); @@ -78,6 +79,24 @@ public static int getIntOrThrow(String input) throws TownyException { return i; } + private static String parseAbbreviations(String input) { + if (input.endsWith("k") || input.endsWith("K")) + return parseNumbers(input) + "000"; + if (input.endsWith("m") || input.endsWith("M")) + return parseNumbers(input) + "000000"; + if (input.endsWith("b") || input.endsWith("B")) + return parseNumbers(input) + "000000000"; + return input; + } + + private static String parseNumbers(String input) { + String output = ""; + for (int i = 0; i < input.length(); i++) + if (Character.isDigit(input.charAt(i))) + output += input.charAt(i); + return output; + } + public static int getPositiveIntOrThrow(String input) throws TownyException { int i = getIntOrThrow(input); if (i < 0) diff --git a/Towny/src/main/resources/ChangeLog.txt b/Towny/src/main/resources/ChangeLog.txt index 2d25c7b5f2..26128551f0 100644 --- a/Towny/src/main/resources/ChangeLog.txt +++ b/Towny/src/main/resources/ChangeLog.txt @@ -10234,4 +10234,7 @@ v0.92.0.11: - While true, conquered towns will be considered a member of good standing in the nation, and will be treated as normal nation members when plot perms are calculated. - When set to false plot permission tests will treat conquered towns' residents as not members of their nations, preventing them from using their host nation's plots while the nation's towns have nation plot perms enabled. - Add optional -ignore subcommand to /town leave. - - When used, the player will not have to confirm their leaving the town. \ No newline at end of file + - When used, the player will not have to confirm their leaving the town. + - Add the ability to use k, m and b in various money commands in Towny. + - ex: /t deposit 1k, will deposit 1000 into the town bank. + - Closes #7759. \ No newline at end of file