Merge branch 'development'

This commit is contained in:
Brianna 2020-09-25 11:46:45 -05:00
commit ad28b239d9
20 changed files with 79 additions and 24 deletions

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../</relativePath>
</parent>

View File

@ -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 <br>
* 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

View File

@ -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<Economy> 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;
}
}

View File

@ -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+");
}
}

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.8</version>
<version>2.4.9</version>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>