Merge branch 'development'

This commit is contained in:
Brianna 2020-09-17 08:39:33 -05:00
commit c3014b55b1
22 changed files with 34 additions and 41 deletions

View File

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

View File

@ -55,7 +55,7 @@ public class SongodaCore {
* This has been added as of Rev 6 <br>
* This value is automatically filled in by gitlab-ci
*/
private final static String coreVersion = "2.4.5";
private final static String coreVersion = "2.4.6";
/**
* This is specific to the website api

View File

@ -3,11 +3,15 @@ package com.songoda.core.hooks;
import com.songoda.core.hooks.economies.Economy;
import org.bukkit.OfflinePlayer;
import java.text.DecimalFormat;
/**
* A convenience class for static access to an Economy HookManager
*/
public class EconomyManager {
private static String currencySymbol = "$";
private static final HookManager<Economy> manager = new HookManager(Economy.class);
/**
@ -58,8 +62,9 @@ public class EconomyManager {
* @param amt amount to display
* @return a currency string as formatted by the economy plugin
*/
public static String formatEconomy(double amt) {
return manager.isEnabled() ? manager.getCurrentHook().formatEconomy(amt) : String.valueOf(amt);
public String formatEconomy(double amt) {
DecimalFormat formatter = new DecimalFormat(amt == Math.ceil(amt) ? "#,###" : "#,###.00");
return currencySymbol + formatter.format(amt);
}
/**
@ -110,4 +115,13 @@ public class EconomyManager {
public static boolean deposit(OfflinePlayer player, double amount) {
return manager.isEnabled() && manager.getCurrentHook().deposit(player, amount);
}
/**
* Change the curency symbl used in the #formatEconomy method.
*
* @param currencySymbol the new symbol
*/
public static void setCurrencySymbol(String currencySymbol) {
EconomyManager.currencySymbol = currencySymbol;
}
}

View File

@ -41,15 +41,4 @@ public abstract class Economy implements Hook {
* @return true if the total amount was added successfully
*/
public abstract boolean deposit(OfflinePlayer player, double amount);
/**
* Format the given amount to a human-readable string in this currency
*
* @param amt amount to display
* @return a currency string as formatted by the economy plugin
*/
public String formatEconomy(double amt) {
DecimalFormat formatter = new DecimalFormat(amt == Math.ceil(amt) ? "#,###" : "#,###.00");
return "$" + formatter.format(amt);
}
}

View File

@ -25,11 +25,6 @@ public class ReserveEconomy extends Economy {
return "Reserve";
}
@Override
public String formatEconomy(double amt) {
return economyAPI.format(BigDecimal.valueOf(amt));
}
@Override
public double getBalance(OfflinePlayer player) {
return economyAPI.getBankHoldings(player.getUniqueId()).doubleValue();

View File

@ -29,11 +29,6 @@ public class VaultEconomy extends Economy {
return "Vault";
}
@Override
public String formatEconomy(double amt) {
return vault != null ? vault.format(amt) : super.formatEconomy(amt);
}
@Override
public double getBalance(OfflinePlayer player) {
if (vault == null)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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