本文整理汇总了Java中net.milkbowl.vault.economy.EconomyResponse.ResponseType.FAILURE属性的典型用法代码示例。如果您正苦于以下问题:Java ResponseType.FAILURE属性的具体用法?Java ResponseType.FAILURE怎么用?Java ResponseType.FAILURE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.milkbowl.vault.economy.EconomyResponse.ResponseType
的用法示例。
在下文中一共展示了ResponseType.FAILURE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: withdrawPlayer
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Can't deposit negative amount");
}
switch (db.withdrawPlayer(playerName, amount)) {
case ACCOUNT_NOT_FOUND:
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Account not found");
case NOT_ENOUGH:
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Money is not enough");
case SUCCESS:
return new EconomyResponse(amount, db.getBalance(playerName), ResponseType.SUCCESS, "");
default:
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unknown error");
}
}
示例2: withdrawPlayer
@Override
public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) {
// grab any coins in inventory first
double residual = new InventoryCoins(player.getPlayer()).collectCoinPayment(amount);
// then grab remaining balance from account
if (residual > 0) {
String accountNumber = UniversalAccounts.getInstance().getPlayerAccount(player.getUniqueId().toString());
if (UniversalAccounts.getInstance().debitAccount(accountNumber, (int) residual)) {
return new EconomyResponse(amount, 0, ResponseType.SUCCESS, null);
} else {
// return coins taken since payment could not be completed
new InventoryCoins(player.getPlayer()).returnChange(amount - residual);
return new EconomyResponse(amount, 0, ResponseType.FAILURE, "Withdrawal failed");
}
}
return new EconomyResponse(amount, 0, ResponseType.SUCCESS, null);
}
示例3: withdrawPlayer
@Override
public EconomyResponse withdrawPlayer(OfflinePlayer player, double amount) {
if (!(player instanceof OfflinePlayer)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, String.format(plugin.getMessage("InvalidPlayer"), "Unknown"));
}
double balance = players.get(player.getUniqueId()).getBalance();
if (amount < 0) {
return new EconomyResponse(amount, balance, ResponseType.FAILURE, plugin.getMessage("NegativeAmountUsed"));
}
String displayAmount = format(amount);
if (balance < amount) {
return new EconomyResponse(amount, balance, ResponseType.FAILURE, String.format(plugin.getMessage("InsufficientFunds"), displayAmount));
}
balance = players.get(player.getUniqueId()).withdraw(amount);
if (plugin.getLogTransactions()) {
plugin.getLogger().info(String.format("Withdraw Player: %s %s%12.2f", player.getName(), plugin.getCurrencySymbol(), amount));
}
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, String.format(plugin.getMessage("Withdraw"), displayAmount));
}
示例4: withdrawPlayer
@Override
public final EconomyResponse withdrawPlayer(final String playerName, final double amount) {
double balance = getBalance(playerName);
if(amount < 0) {
return new EconomyResponse(amount, balance, ResponseType.FAILURE, "Cannot withdraw negative funds.");
}
if(!has(playerName, amount)) {
return new EconomyResponse(amount, balance, ResponseType.FAILURE, "Insufficient funds.");
}
if(!hasAccount(playerName)) {
return new EconomyResponse(amount, balance, ResponseType.FAILURE, "This player does not exist or does not have an account.");
}
final SkyowalletAccount account = getAccountByName(playerName);
balance -= account.getWallet();
account.setWallet(balance);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "Success.");
}
示例5: createBank
@Override
public final EconomyResponse createBank(final String bankName, final String playerName) {
if(!Utils.isValidFileName(bankName)) {
return new EconomyResponse(0d, 0d, ResponseType.FAILURE, "This is not a valid bank name.");
}
if(SkyowalletAPI.isBankExists(bankName)) {
return new EconomyResponse(0d, 0d, ResponseType.FAILURE, "A bank with the same name already exists.");
}
if(!hasAccount(playerName)) {
return new EconomyResponse(0d, 0d, ResponseType.FAILURE, "This player does not exist or does not have an account.");
}
final SkyowalletBank bank = SkyowalletAPI.createBank(bankName);
final SkyowalletAccount account = getAccountByName(playerName);
account.setBank(bank, false);
account.setBankOwner(true);
return new EconomyResponse(0d, 0d, ResponseType.SUCCESS, "Success.");
}
示例6: withdrawPlayer
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds!");
}
if (!GoldIsMoney.hasAccount(playerName)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player does not have an account!");
}
if (!GoldIsMoney.has(playerName, amount)) {
return new EconomyResponse(0, GoldIsMoney.getBalance(playerName), ResponseType.FAILURE, "Insufficient funds");
}
if (!GoldIsMoney.withdrawPlayer(playerName, amount)) {
return new EconomyResponse(0, GoldIsMoney.getBalance(playerName), ResponseType.FAILURE, "Unable to withdraw funds!");
}
return new EconomyResponse(amount, GoldIsMoney.getBalance(playerName), ResponseType.SUCCESS, null);
}
示例7: isBankMember
@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!");
}
}
示例8: depositPlayer
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Can't deposit negative amount");
}
switch (db.depositPlayer(playerName, amount)) {
case ACCOUNT_NOT_FOUND:
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Account not found");
case SUCCESS:
return new EconomyResponse(amount, db.getBalance(playerName), ResponseType.SUCCESS, "");
default:
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unknown error");
}
}
示例9: depositPlayer
@SuppressWarnings("deprecation")
@Override
public EconomyResponse depositPlayer(String arg0, double arg1) {
Player player = Bukkit.getPlayer(arg0);
if (player == null)
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Failed to get offline player");
return depositPlayer(player, arg1);
}
示例10: withdrawPlayer
private EconomyResponse withdrawPlayer(Account account, double amount) {
TransactionResult removed = account.remove(amount);
switch (removed) {
case SUCCESS:
return new EconomyResponse(amount, account.balance(), ResponseType.SUCCESS, null);
case INSUFFICIENT_FUNDS:
return new EconomyResponse(0, account.balance(), ResponseType.FAILURE, LANG.plugin_vault_insufficientFunds);
case ERROR:
default:
return new EconomyResponse(0, account.balance(), ResponseType.FAILURE, LANG.plugin_vault_error);
}
}
示例11: depositPlayer
private EconomyResponse depositPlayer(Account account, double amount) {
TransactionResult added = account.add(amount);
switch (added) {
case SUCCESS:
return new EconomyResponse(amount, account.balance(), ResponseType.SUCCESS, null);
case INSUFFICIENT_SPACE:
return new EconomyResponse(0, account.balance(), ResponseType.FAILURE, LANG.plugin_vault_insufficientSpace);
case ERROR:
default:
return new EconomyResponse(0, account.balance(), ResponseType.FAILURE, LANG.plugin_vault_error);
}
}
示例12: depositPlayer
@Override
public EconomyResponse depositPlayer(String player, String world, double amount) {
if(amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot deposit negative funds");
}
if(!this.hasAccount(player, world)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player does not have an account in this world.");
}
this.manager.getWorld(world).getPlayer(player).addBalance(amount);
return new EconomyResponse(amount, this.getBalance(player, world), ResponseType.SUCCESS, null);
}
示例13: withdrawPlayer
@Override
public EconomyResponse withdrawPlayer(String player, String world, double amount) {
if(amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
if(!this.hasAccount(player, world)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player does not have an account in this world.");
}
this.manager.getWorld(world).getPlayer(player).removeBalance(amount);
return new EconomyResponse(amount, this.getBalance(player, world), ResponseType.SUCCESS, null);
}
示例14: bankBalance
@Override
public EconomyResponse bankBalance(String bankName)
{
if (!plugin.getBanks().containsKey(bankName)) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
}
Bank bank = plugin.getBank(bankName);
return new EconomyResponse(0, bank.getTotalDeposits(), ResponseType.SUCCESS, "Total of all deposits");
}
示例15: depositPlayer
@Override
public EconomyResponse depositPlayer(OfflinePlayer offlinePlayer, double amount)
{
Player player = getPlayer(offlinePlayer);
double balance = player.deposit(amount);
if (amount < 0) {
return new EconomyResponse(amount, balance, ResponseType.FAILURE, plugin.getMessage("NegativeAmountUsed"));
}
if (plugin.getLogTransactions()) {
plugin.getLogger().info(String.format("Deposit Player: %s %s%12.2f", player.getName(), plugin.getCurrencySymbol(), amount));
}
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, plugin.getMessage("Deposit", format(balance)));
}