mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-27 12:35:12 +01:00
Merge branch 'development'
This commit is contained in:
commit
dc783eaf8a
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "SongodaCore"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.3"
|
||||
version: "2.3.1"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -61,6 +61,19 @@ public class EconomyManager {
|
||||
return manager.isEnabled() ? manager.getCurrentHook().formatEconomy(amt) : String.valueOf(amt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the players available balance
|
||||
*
|
||||
* @param player player
|
||||
* @return the amount of available balance
|
||||
*/
|
||||
public static double getBalance(OfflinePlayer player) {
|
||||
if (!manager.isEnabled())
|
||||
return 0;
|
||||
return manager.getCurrentHook().getBalance(player);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a player has at least some balance available. <br />
|
||||
* NOTE: using a default economy assumes that this library is shaded
|
||||
|
@ -6,6 +6,14 @@ import org.bukkit.OfflinePlayer;
|
||||
|
||||
public abstract class Economy implements Hook {
|
||||
|
||||
/**
|
||||
* Get the players available balance
|
||||
*
|
||||
* @param player player
|
||||
* @return the amount of available balance
|
||||
*/
|
||||
public abstract double getBalance(OfflinePlayer player);
|
||||
|
||||
/**
|
||||
* Check to see if a player has at least some balance available
|
||||
*
|
||||
|
@ -26,6 +26,11 @@ public class PlayerPointsEconomy extends Economy {
|
||||
return "PlayerPoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(OfflinePlayer player) {
|
||||
return playerPoints.getAPI().look(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBalance(OfflinePlayer player, double cost) {
|
||||
int amount = convertAmount(cost);
|
||||
|
@ -30,6 +30,11 @@ public class ReserveEconomy extends Economy {
|
||||
return economyAPI.format(BigDecimal.valueOf(amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(OfflinePlayer player) {
|
||||
return economyAPI.getBankHoldings(player.getUniqueId()).doubleValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBalance(OfflinePlayer player, double cost) {
|
||||
return economyAPI.hasHoldings(player.getUniqueId(), new BigDecimal(cost));
|
||||
|
@ -9,7 +9,7 @@ public class VaultEconomy extends Economy {
|
||||
private final net.milkbowl.vault.economy.Economy vault;
|
||||
|
||||
public VaultEconomy() {
|
||||
// this returns null if we have Vault with no compatibe eco plugin
|
||||
// this returns null if we have Vault with no compatible eco plugin
|
||||
RegisteredServiceProvider<net.milkbowl.vault.economy.Economy> v = Bukkit.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if(v != null) {
|
||||
this.vault = v.getProvider();
|
||||
@ -34,6 +34,13 @@ public class VaultEconomy extends Economy {
|
||||
return vault != null ? vault.format(amt) : super.formatEconomy(amt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(OfflinePlayer player) {
|
||||
if (vault == null)
|
||||
return 0;
|
||||
return vault.getBalance(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBalance(OfflinePlayer player, double cost) {
|
||||
return vault != null && vault.has(player, cost);
|
||||
|
Loading…
Reference in New Issue
Block a user