diff --git a/Core/pom.xml b/Core/pom.xml
index 67ab4825..60f3e7f9 100644
--- a/Core/pom.xml
+++ b/Core/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../
diff --git a/Core/src/main/java/com/songoda/core/SongodaCore.java b/Core/src/main/java/com/songoda/core/SongodaCore.java
index c1162b1c..296e20d2 100644
--- a/Core/src/main/java/com/songoda/core/SongodaCore.java
+++ b/Core/src/main/java/com/songoda/core/SongodaCore.java
@@ -49,13 +49,12 @@ public class SongodaCore {
* Whenever we make a major change to the core GUI, updater,
* or other function used by the core, increment this number
*/
- private final static int coreRevision = 6;
+ private final static int coreRevision = 7;
/**
- * This has been added as of Rev 6
- * This value is automatically filled in by gitlab-ci
+ * This has been added as of Rev 6
*/
- private final static String coreVersion = "2.4.8";
+ private final static String coreVersion = "2.4.9";
/**
* This is specific to the website api
diff --git a/Core/src/main/java/com/songoda/core/hooks/EconomyManager.java b/Core/src/main/java/com/songoda/core/hooks/EconomyManager.java
index e2711bd2..7b0b36f0 100644
--- a/Core/src/main/java/com/songoda/core/hooks/EconomyManager.java
+++ b/Core/src/main/java/com/songoda/core/hooks/EconomyManager.java
@@ -1,6 +1,7 @@
package com.songoda.core.hooks;
import com.songoda.core.hooks.economies.Economy;
+import com.songoda.core.utils.NumberUtils;
import org.bukkit.OfflinePlayer;
import java.text.DecimalFormat;
@@ -10,7 +11,7 @@ import java.text.DecimalFormat;
*/
public class EconomyManager {
- private static String currencySymbol = "$";
+ private static char currencySymbol = '$';
private static final HookManager manager = new HookManager(Economy.class);
@@ -63,8 +64,7 @@ public class EconomyManager {
* @return a currency string as formatted by the economy plugin
*/
public static String formatEconomy(double amt) {
- DecimalFormat formatter = new DecimalFormat(amt == Math.ceil(amt) ? "#,###" : "#,###.00");
- return currencySymbol + formatter.format(amt);
+ return NumberUtils.formatEconomy(currencySymbol, amt);
}
/**
@@ -122,6 +122,15 @@ public class EconomyManager {
* @param currencySymbol the new symbol
*/
public static void setCurrencySymbol(String currencySymbol) {
+ EconomyManager.currencySymbol = currencySymbol.charAt(0);
+ }
+
+ /**
+ * Change the curency symbl used in the #formatEconomy method.
+ *
+ * @param currencySymbol the new symbol
+ */
+ public static void setCurrencySymbol(char currencySymbol) {
EconomyManager.currencySymbol = currencySymbol;
}
}
diff --git a/Core/src/main/java/com/songoda/core/utils/NumberUtils.java b/Core/src/main/java/com/songoda/core/utils/NumberUtils.java
new file mode 100644
index 00000000..6b308055
--- /dev/null
+++ b/Core/src/main/java/com/songoda/core/utils/NumberUtils.java
@@ -0,0 +1,47 @@
+package com.songoda.core.utils;
+
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+
+public class NumberUtils {
+
+ public static String formatEconomy(char currencySymbol, double number) {
+ return currencySymbol + formatNumber(number);
+ }
+
+ public static String formatNumber(double number) {
+ DecimalFormat decimalFormatter = new DecimalFormat(number == Math.ceil(number) ? "#,###" : "#,###.00");
+
+ // This is done to specifically prevent the NBSP character from printing in foreign languages.
+ DecimalFormatSymbols symbols = decimalFormatter.getDecimalFormatSymbols();
+ symbols.setGroupingSeparator(',');
+
+ decimalFormatter.setDecimalFormatSymbols(symbols);
+ return decimalFormatter.format(number);
+ }
+
+ public static String formatWithSuffix(long count) {
+ if (count < 1000) return String.valueOf(count);
+ int exp = (int) (Math.log(count) / Math.log(1000));
+ return String.format("%.1f%c", count / Math.pow(1000, exp),
+ "kMGTPE".charAt(exp-1)).replace(".0", "");
+ }
+
+ public static boolean isInt(String number) {
+ if (number == null || number.equals(""))
+ return false;
+ try {
+ Integer.parseInt(number);
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean isNumeric(String s) {
+ if (s == null || s.equals(""))
+ return false;
+ return s.matches("[-+]?\\d*\\.?\\d+");
+ }
+
+}
diff --git a/NMS/NMS-API/pom.xml b/NMS/NMS-API/pom.xml
index 0d08effe..4d39b4cc 100644
--- a/NMS/NMS-API/pom.xml
+++ b/NMS/NMS-API/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_10_R1/pom.xml b/NMS/NMS-v1_10_R1/pom.xml
index 6678c78f..b44c76a5 100644
--- a/NMS/NMS-v1_10_R1/pom.xml
+++ b/NMS/NMS-v1_10_R1/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_11_R1/pom.xml b/NMS/NMS-v1_11_R1/pom.xml
index 72bee4a7..154905f2 100644
--- a/NMS/NMS-v1_11_R1/pom.xml
+++ b/NMS/NMS-v1_11_R1/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_12_R1/pom.xml b/NMS/NMS-v1_12_R1/pom.xml
index f37bb3e0..81c6eaa7 100644
--- a/NMS/NMS-v1_12_R1/pom.xml
+++ b/NMS/NMS-v1_12_R1/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_13_R1/pom.xml b/NMS/NMS-v1_13_R1/pom.xml
index 599312df..44d4c473 100644
--- a/NMS/NMS-v1_13_R1/pom.xml
+++ b/NMS/NMS-v1_13_R1/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_13_R2/pom.xml b/NMS/NMS-v1_13_R2/pom.xml
index 351b1f13..1fee199c 100644
--- a/NMS/NMS-v1_13_R2/pom.xml
+++ b/NMS/NMS-v1_13_R2/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_14_R1/pom.xml b/NMS/NMS-v1_14_R1/pom.xml
index fbbc6890..9568efe6 100644
--- a/NMS/NMS-v1_14_R1/pom.xml
+++ b/NMS/NMS-v1_14_R1/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_15_R1/pom.xml b/NMS/NMS-v1_15_R1/pom.xml
index 027f4e31..c4a85c24 100644
--- a/NMS/NMS-v1_15_R1/pom.xml
+++ b/NMS/NMS-v1_15_R1/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_16_R1/pom.xml b/NMS/NMS-v1_16_R1/pom.xml
index 8367568f..f0277abd 100644
--- a/NMS/NMS-v1_16_R1/pom.xml
+++ b/NMS/NMS-v1_16_R1/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_16_R2/pom.xml b/NMS/NMS-v1_16_R2/pom.xml
index d6f5c6dd..06377c25 100644
--- a/NMS/NMS-v1_16_R2/pom.xml
+++ b/NMS/NMS-v1_16_R2/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_8_R1/pom.xml b/NMS/NMS-v1_8_R1/pom.xml
index f0260dbb..32de1930 100644
--- a/NMS/NMS-v1_8_R1/pom.xml
+++ b/NMS/NMS-v1_8_R1/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_8_R2/pom.xml b/NMS/NMS-v1_8_R2/pom.xml
index d683fb17..ea791e51 100644
--- a/NMS/NMS-v1_8_R2/pom.xml
+++ b/NMS/NMS-v1_8_R2/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_8_R3/pom.xml b/NMS/NMS-v1_8_R3/pom.xml
index 633de2fc..49d61d0f 100644
--- a/NMS/NMS-v1_8_R3/pom.xml
+++ b/NMS/NMS-v1_8_R3/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_9_R1/pom.xml b/NMS/NMS-v1_9_R1/pom.xml
index 91473166..67ead1e7 100644
--- a/NMS/NMS-v1_9_R1/pom.xml
+++ b/NMS/NMS-v1_9_R1/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/NMS/NMS-v1_9_R2/pom.xml b/NMS/NMS-v1_9_R2/pom.xml
index edca12a6..ba340c48 100644
--- a/NMS/NMS-v1_9_R2/pom.xml
+++ b/NMS/NMS-v1_9_R2/pom.xml
@@ -3,7 +3,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
../../
diff --git a/pom.xml b/pom.xml
index 5309c004..cf564bb5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
com.songoda
SongodaCore-Modules
- 2.4.8
+ 2.4.9
4.0.0
pom