ChestShop-3/com/Acrobot/ChestShop/Economy/Vault.java

64 lines
1.7 KiB
Java
Raw Normal View History

package com.Acrobot.ChestShop.Economy;
2012-06-25 17:16:24 +02:00
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
/**
* @author Acrobot
*/
public class Vault extends EconomyManager {
private static net.milkbowl.vault.economy.Economy vaultPlugin;
2013-02-01 19:28:42 +01:00
public boolean transactionCanFail() {
return getPluginName().equals("Gringotts") || getPluginName().equals("GoldIsMoney") || getPluginName().equals("MultiCurrency");
}
public boolean hasAccount(String player) {
return vaultPlugin.hasAccount(player);
}
public boolean add(String player, double amount) {
return vaultPlugin.depositPlayer(player, amount).transactionSuccess();
}
public boolean subtract(String player, double amount) {
return vaultPlugin.withdrawPlayer(player, amount).transactionSuccess();
}
public boolean hasEnough(String player, double amount) {
return vaultPlugin.has(player, amount);
}
public double balance(String player) {
return vaultPlugin.getBalance(player);
}
public String format(double amount) {
return vaultPlugin.format(amount);
}
2012-06-25 17:16:24 +02:00
public static String getPluginName() {
if (vaultPlugin == null) {
2012-06-25 17:16:24 +02:00
return "";
} else {
return vaultPlugin.getName();
2012-06-25 17:16:24 +02:00
}
}
public static Vault getVault() {
RegisteredServiceProvider<net.milkbowl.vault.economy.Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (rsp == null) {
return null;
}
vaultPlugin = rsp.getProvider();
2012-06-25 17:16:24 +02:00
if (vaultPlugin == null) {
2012-06-25 17:16:24 +02:00
return null;
} else {
return new Vault();
}
}
}