Adds a method for checking if a player can afford a given fee

This commit is contained in:
Kristian Knarvik 2021-10-18 03:36:56 +02:00
parent d9ae5456cc
commit f96e8ed2da

View File

@ -103,6 +103,17 @@ public final class EconomyHandler {
return EconomyHandler.chargePlayer(player, cost);
}
/**
* Checks whether the given player can afford the given fee
*
* @param player <p>The player to check</p>
* @param cost <p>The fee to pay</p>
* @return <p>True if the player can afford to pay the fee</p>
*/
public static boolean canAffordFee(Player player, int cost) {
return economy.getBalance(player) > cost;
}
/**
* Charges the player for an action, if required
*
@ -188,7 +199,7 @@ public final class EconomyHandler {
* @param destination <p>The destination portal</p>
* @return <p>The cost of using the portal</p>
*/
public static int getDefaultUseCost(Player player, Portal source, Portal destination) {
public static int getUseCost(Player player, Portal source, Portal destination) {
//No payment required
if (!EconomyHandler.useEconomy() || source.getOptions().isFree()) {
return 0;