mirror of https://github.com/MilkBowl/Vault.git
updated economy methods to expose currencyNamePlural/Singular methods.
added conversion command to convert from one economy to another.
This commit is contained in:
parent
a02f73cd6c
commit
c6c5dba151
|
@ -15,7 +15,10 @@ commands:
|
|||
description: Reloads Vault
|
||||
usage: |
|
||||
/<command> - Reloads Vault
|
||||
|
||||
vault-convert:
|
||||
description: Converts all data in economy1 and dumps it into economy2
|
||||
usage: |
|
||||
/<command> [economy1] [economy2]
|
||||
permissions:
|
||||
vault.admin:
|
||||
description: Notifies the player when vault is in need of an update.
|
||||
|
|
|
@ -59,9 +59,10 @@ import net.milkbowl.vault.permission.plugins.Permission_bPermissions;
|
|||
import net.milkbowl.vault.permission.plugins.Permission_bPermissions2;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_zPermissions;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -107,6 +108,7 @@ public class Vault extends JavaPlugin {
|
|||
|
||||
getCommand("vault-info").setExecutor(this);
|
||||
getCommand("vault-reload").setExecutor(this);
|
||||
getCommand("vault-convert").setExecutor(this);
|
||||
getServer().getPluginManager().registerEvents(new VaultListener(), this);
|
||||
|
||||
// Schedule to check the version every 30 minutes for an update. This is to update the most recent
|
||||
|
@ -380,55 +382,99 @@ public class Vault extends JavaPlugin {
|
|||
if (!p.isOp()) {
|
||||
return true;
|
||||
}
|
||||
} else if (!(sender instanceof ConsoleCommandSender)) {
|
||||
// Check if NOT console
|
||||
// Ignore it if not originated from Console!
|
||||
return true;
|
||||
}
|
||||
|
||||
if (command.getLabel().equals("vault-info")) {
|
||||
|
||||
// Get String of Registered Economy Services
|
||||
String registeredEcons = null;
|
||||
Collection<RegisteredServiceProvider<Economy>> econs = this.getServer().getServicesManager().getRegistrations(Economy.class);
|
||||
for (RegisteredServiceProvider<Economy> econ : econs) {
|
||||
Economy e = econ.getProvider();
|
||||
if (registeredEcons == null) {
|
||||
registeredEcons = e.getName();
|
||||
} else {
|
||||
registeredEcons += ", " + e.getName();
|
||||
}
|
||||
}
|
||||
|
||||
// Get String of Registered Permission Services
|
||||
String registeredPerms = null;
|
||||
Collection<RegisteredServiceProvider<Permission>> perms = this.getServer().getServicesManager().getRegistrations(Permission.class);
|
||||
for (RegisteredServiceProvider<Permission> perm : perms) {
|
||||
Permission p = perm.getProvider();
|
||||
if (registeredPerms == null) {
|
||||
registeredPerms = p.getName();
|
||||
} else {
|
||||
registeredPerms += ", " + p.getName();
|
||||
}
|
||||
}
|
||||
|
||||
// Get Economy & Permission primary Services
|
||||
Economy econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
|
||||
Permission perm = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
|
||||
|
||||
// Send user some info!
|
||||
sender.sendMessage(String.format("[%s] Vault v%s Information", getDescription().getName(), getDescription().getVersion()));
|
||||
sender.sendMessage(String.format("[%s] Economy: %s [%s]", getDescription().getName(), econ.getName(), registeredEcons));
|
||||
sender.sendMessage(String.format("[%s] Permission: %s [%s]", getDescription().getName(), perm.getName(), registeredPerms));
|
||||
if (command.getName().equalsIgnoreCase("vault-info")) {
|
||||
infoCommand(sender);
|
||||
return true;
|
||||
} else {
|
||||
} else if (command.getName().equalsIgnoreCase("vault-convert")) {
|
||||
convertCommand(sender, args);
|
||||
return true;
|
||||
}else {
|
||||
// Show help
|
||||
sender.sendMessage("Vault Commands:");
|
||||
sender.sendMessage(" /vault-info - Displays information about Vault");
|
||||
sender.sendMessage(" /vault-convert [economy1] [economy2] - Converts from one Economy to another");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void convertCommand(CommandSender sender, String[] args) {
|
||||
Collection<RegisteredServiceProvider<Economy>> econs = this.getServer().getServicesManager().getRegistrations(Economy.class);
|
||||
if (econs == null || econs.size() < 2) {
|
||||
sender.sendMessage("You must have at least 2 economies loaded to convert.");
|
||||
return;
|
||||
} else if (args.length != 2) {
|
||||
sender.sendMessage("You must specify only the economy to convert from and the economy to convert to. (without spaces)");
|
||||
return;
|
||||
}
|
||||
Economy econ1 = null;
|
||||
Economy econ2 = null;
|
||||
for (RegisteredServiceProvider<Economy> econ : econs) {
|
||||
String econName = econ.getProvider().getName().replace(" ", "");
|
||||
if (econName.equalsIgnoreCase(args[0])) {
|
||||
econ1 = econ.getProvider();
|
||||
} else if (econName.equalsIgnoreCase(args[1])) {
|
||||
econ2 = econ.getProvider();
|
||||
}
|
||||
}
|
||||
|
||||
if (econ1 == null) {
|
||||
sender.sendMessage("Could not find " + args[0] + " loaded on the server, check your spelling");
|
||||
return;
|
||||
} else if (econ2 == null) {
|
||||
sender.sendMessage("Could not find " + args[1] + " loaded on the server, check your spelling");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage("This may take some time to convert, expect server lag.");
|
||||
for (OfflinePlayer op : Bukkit.getServer().getOfflinePlayers()) {
|
||||
String pName = op.getName();
|
||||
if (econ1.hasAccount(pName)) {
|
||||
if (econ2.hasAccount(pName)) {
|
||||
continue;
|
||||
}
|
||||
econ2.createPlayerAccount(pName);
|
||||
econ2.depositPlayer(pName, econ1.getBalance(pName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void infoCommand(CommandSender sender) {
|
||||
// Get String of Registered Economy Services
|
||||
String registeredEcons = null;
|
||||
Collection<RegisteredServiceProvider<Economy>> econs = this.getServer().getServicesManager().getRegistrations(Economy.class);
|
||||
for (RegisteredServiceProvider<Economy> econ : econs) {
|
||||
Economy e = econ.getProvider();
|
||||
if (registeredEcons == null) {
|
||||
registeredEcons = e.getName();
|
||||
} else {
|
||||
registeredEcons += ", " + e.getName();
|
||||
}
|
||||
}
|
||||
|
||||
// Get String of Registered Permission Services
|
||||
String registeredPerms = null;
|
||||
Collection<RegisteredServiceProvider<Permission>> perms = this.getServer().getServicesManager().getRegistrations(Permission.class);
|
||||
for (RegisteredServiceProvider<Permission> perm : perms) {
|
||||
Permission p = perm.getProvider();
|
||||
if (registeredPerms == null) {
|
||||
registeredPerms = p.getName();
|
||||
} else {
|
||||
registeredPerms += ", " + p.getName();
|
||||
}
|
||||
}
|
||||
|
||||
// Get Economy & Permission primary Services
|
||||
Economy econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
|
||||
Permission perm = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
|
||||
|
||||
// Send user some info!
|
||||
sender.sendMessage(String.format("[%s] Vault v%s Information", getDescription().getName(), getDescription().getVersion()));
|
||||
sender.sendMessage(String.format("[%s] Economy: %s [%s]", getDescription().getName(), econ.getName(), registeredEcons));
|
||||
sender.sendMessage(String.format("[%s] Permission: %s [%s]", getDescription().getName(), perm.getName(), registeredPerms));
|
||||
}
|
||||
|
||||
public synchronized void setVersion(int newVersion) {
|
||||
this.newVersion = newVersion;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public interface Economy {
|
|||
* Returns true if the given implementation supports banks.
|
||||
* @return true if the implementation supports banks
|
||||
*/
|
||||
public abstract boolean hasBankSupport();
|
||||
public boolean hasBankSupport();
|
||||
|
||||
/**
|
||||
* Format amount into a human readable String This provides translation into
|
||||
|
@ -51,6 +51,23 @@ public interface Economy {
|
|||
*/
|
||||
public String format(double amount);
|
||||
|
||||
/**
|
||||
* Returns the name of the currency in plural form.
|
||||
* If the economy being used does not support currency names then an empty string will be returned.
|
||||
*
|
||||
* @return name of the currency (plural)
|
||||
*/
|
||||
public String currencyNamePlural();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the name of the currency in singular form.
|
||||
* If the economy being used does not support currency names then an empty string will be returned.
|
||||
*
|
||||
* @return name of the currency (singular)
|
||||
*/
|
||||
public String currencyNameSingular();
|
||||
|
||||
/**
|
||||
* Checks if this player has an account on the server yet
|
||||
* This will always return true if the player has joined the server at least once
|
||||
|
|
|
@ -135,11 +135,13 @@ public class Economy_3co implements Economy {
|
|||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
|
||||
public String getMoneyNamePlural() {
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return economy.getPluralCurrency();
|
||||
}
|
||||
|
||||
public String getMoneyNameSingular() {
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return economy.getSingularCurrency();
|
||||
}
|
||||
|
||||
|
@ -177,9 +179,9 @@ public class Economy_3co implements Economy {
|
|||
public String format(double amount) {
|
||||
amount = Math.ceil(amount);
|
||||
if (amount == 1) {
|
||||
return String.format("%d %s", (int)amount, getMoneyNameSingular());
|
||||
return String.format("%d %s", (int)amount, currencyNameSingular());
|
||||
} else {
|
||||
return String.format("%d %s", (int)amount, getMoneyNamePlural());
|
||||
return String.format("%d %s", (int)amount, currencyNamePlural());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,11 +149,13 @@ public class Economy_BOSE6 implements Economy {
|
|||
}
|
||||
}
|
||||
|
||||
public String getMoneyNamePlural() {
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return economy.getMoneyNamePlural();
|
||||
}
|
||||
|
||||
public String getMoneyNameSingular() {
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return economy.getMoneyName();
|
||||
}
|
||||
|
||||
|
@ -190,9 +192,9 @@ public class Economy_BOSE6 implements Economy {
|
|||
@Override
|
||||
public String format(double amount) {
|
||||
if (amount == 1) {
|
||||
return String.format("%.0f %s", amount, getMoneyNameSingular());
|
||||
return String.format("%.0f %s", amount, currencyNameSingular());
|
||||
} else {
|
||||
return String.format("%.2f %s", amount, getMoneyNamePlural());
|
||||
return String.format("%.2f %s", amount, currencyNamePlural());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,11 +144,13 @@ public class Economy_BOSE7 implements Economy {
|
|||
}
|
||||
}
|
||||
|
||||
public String getMoneyNamePlural() {
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return economy.getMoneyNamePlural();
|
||||
}
|
||||
|
||||
public String getMoneyNameSingular() {
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return economy.getMoneyName();
|
||||
}
|
||||
|
||||
|
@ -185,9 +187,9 @@ public class Economy_BOSE7 implements Economy {
|
|||
@Override
|
||||
public String format(double amount) {
|
||||
if (amount == 1) {
|
||||
return String.format("%.0f %s", amount, getMoneyNameSingular());
|
||||
return String.format("%.0f %s", amount, currencyNameSingular());
|
||||
} else {
|
||||
return String.format("%.2f %s", amount, getMoneyNamePlural());
|
||||
return String.format("%.2f %s", amount, currencyNamePlural());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,7 +199,6 @@ public class Economy_BOSE7 implements Economy {
|
|||
if (success) {
|
||||
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account.");
|
||||
}
|
||||
|
||||
|
@ -212,23 +213,24 @@ public class Economy_BOSE7 implements Economy {
|
|||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
if (!economy.bankExists(name))
|
||||
if (!economy.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
|
||||
}
|
||||
|
||||
double bankMoney = economy.getBankMoneyDouble(name);
|
||||
if (bankMoney < amount)
|
||||
if (bankMoney < amount) {
|
||||
return new EconomyResponse(0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!");
|
||||
else
|
||||
} else {
|
||||
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, "");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
EconomyResponse er = bankHas(name, amount);
|
||||
if (!er.transactionSuccess())
|
||||
if (!er.transactionSuccess()) {
|
||||
return er;
|
||||
else {
|
||||
} else {
|
||||
economy.addBankMoney(name, -amount, true);
|
||||
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
@ -256,18 +258,20 @@ public class Economy_BOSE7 implements Economy {
|
|||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
if (!economy.bankExists(name))
|
||||
if (!economy.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
else if (economy.isBankMember(name, playerName)) {
|
||||
} else if (economy.isBankMember(name, playerName)) {
|
||||
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
} else
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank member!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
if (!economy.bankExists(name))
|
||||
if (!economy.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
double bankMoney = economy.getBankMoneyDouble(name);
|
||||
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null);
|
||||
|
|
|
@ -109,6 +109,16 @@ public class Economy_Craftconomy implements Economy {
|
|||
return Craftconomy.format(amount, CurrencyHandler.getCurrency(Config.currencyDefault, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return CurrencyHandler.getCurrency(Config.currencyDefault, true).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return CurrencyHandler.getCurrency(Config.currencyDefault, true).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
if (AccountHandler.exists(playerName)) {
|
||||
|
@ -144,108 +154,108 @@ public class Economy_Craftconomy implements Economy {
|
|||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
boolean success = BankHandler.create(name, player);
|
||||
boolean success = BankHandler.create(name, player);
|
||||
if (success) {
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
boolean success = BankHandler.delete(name);
|
||||
if (success) {
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account.");
|
||||
boolean success = BankHandler.delete(name);
|
||||
if (success) {
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
|
||||
if (BankHandler.exists(name))
|
||||
{
|
||||
Bank bank = BankHandler.getBank(name);
|
||||
if (bank.hasEnough(amount))
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
else
|
||||
return new EconomyResponse(0, bank.getDefaultBalance(), ResponseType.FAILURE, "The bank does not have enough money!");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
|
||||
if (BankHandler.exists(name))
|
||||
{
|
||||
Bank bank = BankHandler.getBank(name);
|
||||
if (bank.hasEnough(amount))
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
else
|
||||
return new EconomyResponse(0, bank.getDefaultBalance(), ResponseType.FAILURE, "The bank does not have enough money!");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
EconomyResponse er = bankHas(name, amount);
|
||||
EconomyResponse er = bankHas(name, amount);
|
||||
if (!er.transactionSuccess())
|
||||
return er;
|
||||
else
|
||||
{
|
||||
if (BankHandler.exists(name))
|
||||
{
|
||||
Bank bank = BankHandler.getBank(name);
|
||||
double balance = bank.substractMoney(amount);
|
||||
return new EconomyResponse(0, balance, ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
if (BankHandler.exists(name))
|
||||
{
|
||||
Bank bank = BankHandler.getBank(name);
|
||||
double balance = bank.substractMoney(amount);
|
||||
return new EconomyResponse(0, balance, ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
if (BankHandler.exists(name))
|
||||
{
|
||||
Bank bank = BankHandler.getBank(name);
|
||||
double balance = bank.addMoney(amount);
|
||||
return new EconomyResponse(0, balance, ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
if (BankHandler.exists(name))
|
||||
{
|
||||
Bank bank = BankHandler.getBank(name);
|
||||
double balance = bank.addMoney(amount);
|
||||
return new EconomyResponse(0, balance, ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
if (BankHandler.exists(name))
|
||||
{
|
||||
Bank bank = BankHandler.getBank(name);
|
||||
if (bank.getOwner().equals(playerName))
|
||||
{
|
||||
return new EconomyResponse(0, bank.getDefaultBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "This player is not the owner of the bank!");
|
||||
Bank bank = BankHandler.getBank(name);
|
||||
if (bank.getOwner().equals(playerName))
|
||||
{
|
||||
return new EconomyResponse(0, bank.getDefaultBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "This player is not the owner of the bank!");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
EconomyResponse er = isBankOwner(name,playerName);
|
||||
if (er.transactionSuccess())
|
||||
return er;
|
||||
else
|
||||
{
|
||||
if (BankHandler.exists(name))
|
||||
{
|
||||
Bank bank = BankHandler.getBank(name);
|
||||
Iterator<String> iterator = bank.getMembers().iterator();
|
||||
while(iterator.hasNext())
|
||||
{
|
||||
if (iterator.next().equals(playerName))
|
||||
return new EconomyResponse(0,bank.getDefaultBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "This player is not a member of the bank!");
|
||||
}
|
||||
EconomyResponse er = isBankOwner(name,playerName);
|
||||
if (er.transactionSuccess())
|
||||
return er;
|
||||
else
|
||||
{
|
||||
if (BankHandler.exists(name))
|
||||
{
|
||||
Bank bank = BankHandler.getBank(name);
|
||||
Iterator<String> iterator = bank.getMembers().iterator();
|
||||
while(iterator.hasNext())
|
||||
{
|
||||
if (iterator.next().equals(playerName))
|
||||
return new EconomyResponse(0,bank.getDefaultBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "This player is not a member of the bank!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
if (BankHandler.exists(name))
|
||||
{
|
||||
return new EconomyResponse(0, BankHandler.getBank(name).getDefaultBalance(), ResponseType.SUCCESS, "");
|
||||
return new EconomyResponse(0, BankHandler.getBank(name).getDefaultBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
|
|
@ -98,6 +98,16 @@ public class Economy_CurrencyCore implements Economy {
|
|||
public String format(double amount) {
|
||||
return this.currency.getFormatHelper().format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return currency.getCurrencyConfig().getCurrencyMajor().get(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return currency.getCurrencyConfig().getCurrencyMajor().get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
|
|
|
@ -102,6 +102,16 @@ public class Economy_EconXP implements Economy {
|
|||
return String.format("%d %s", (int)amount, "experience");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return "experience";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return "experience";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
OfflinePlayer player = econ.getPlayer(playerName);
|
||||
|
|
|
@ -199,6 +199,16 @@ public class Economy_Essentials implements Economy {
|
|||
return com.earth2me.essentials.api.Economy.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -91,11 +91,13 @@ public class Economy_McMoney implements Economy {
|
|||
return new EconomyResponse(amount, economy.getMoney(playerName), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
public String getMoneyNamePlural() {
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return economy.moneyNamePlural();
|
||||
}
|
||||
|
||||
public String getMoneyNameSingular() {
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return economy.moneyNameSingle();
|
||||
}
|
||||
|
||||
|
@ -133,9 +135,9 @@ public class Economy_McMoney implements Economy {
|
|||
public String format(double amount) {
|
||||
amount = Math.ceil(amount);
|
||||
if (amount == 1) {
|
||||
return String.format("%d %s", (int)amount, getMoneyNameSingular());
|
||||
return String.format("%d %s", (int)amount, currencyNameSingular());
|
||||
} else {
|
||||
return String.format("%d %s", (int)amount, getMoneyNamePlural());
|
||||
return String.format("%d %s", (int)amount, currencyNamePlural());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,16 @@ public class Economy_MineConomy implements Economy {
|
|||
return String.valueOf(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return Accounting.getBalance(playerName, MineConomy.accounts);
|
||||
|
|
|
@ -179,7 +179,17 @@ public class Economy_MultiCurrency implements Economy {
|
|||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return String.format("%.2f %s", amount, "Currency");
|
||||
return String.format("%.2f %s", amount, "currency");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return "currency";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return "currency";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -103,6 +103,16 @@ public class Economy_eWallet implements Economy {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return econ.singularCurrency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return econ.pluralCurrency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
Integer i = econ.getMoney(playerName);
|
||||
|
|
|
@ -75,11 +75,13 @@ public class Economy_iConomy4 implements Economy {
|
|||
return iConomy.getBank().format(amount);
|
||||
}
|
||||
|
||||
public String getMoneyNamePlural() {
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return iConomy.getBank().getCurrency() + "s";
|
||||
}
|
||||
|
||||
public String getMoneyNameSingular() {
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return iConomy.getBank().getCurrency();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import com.iConomy.iConomy;
|
||||
import com.iConomy.system.Account;
|
||||
import com.iConomy.system.Holdings;
|
||||
import com.iConomy.util.Constants;
|
||||
|
||||
public class Economy_iConomy5 implements Economy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
@ -152,6 +153,24 @@ public class Economy_iConomy5 implements Economy {
|
|||
return iConomy.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
try {
|
||||
return Constants.Major.get(0);
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
try {
|
||||
return Constants.Major.get(1);
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.bukkit.event.server.PluginEnableEvent;
|
|||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.iCo6.Constants;
|
||||
import com.iCo6.iConomy;
|
||||
import com.iCo6.system.Account;
|
||||
import com.iCo6.system.Accounts;
|
||||
|
@ -109,6 +110,16 @@ public class Economy_iConomy6 implements Economy {
|
|||
return iConomy.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return Constants.Nodes.Major.getStringList().get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return Constants.Nodes.Major.getStringList().get(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
if (accounts.exists(playerName))
|
||||
|
|
Loading…
Reference in New Issue