本文整理汇总了Java中net.milkbowl.vault.economy.EconomyResponse.ResponseType.SUCCESS属性的典型用法代码示例。如果您正苦于以下问题:Java ResponseType.SUCCESS属性的具体用法?Java ResponseType.SUCCESS怎么用?Java ResponseType.SUCCESS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.milkbowl.vault.economy.EconomyResponse.ResponseType
的用法示例。
在下文中一共展示了ResponseType.SUCCESS属性的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: bankDeposit
@Override
public EconomyResponse bankDeposit (String name, double amount) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
}
int value = (int) amount;
int balance = groupBank.getBalance();
if (value < 1) {
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
}
groupBank.modifyBalance(value);
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
}
示例7: isBankOwner
@Override
public EconomyResponse isBankOwner (String name, String playerName) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
}
Account account = api.getAccount(name);
if (account == null) {
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
}
if (groupBank.getOwner().equalsIgnoreCase(name)) {
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
}
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("PlayerNotOwner"), account.getName(), groupBank.getName()));
}
示例8: depositPlayer
@Override
public EconomyResponse depositPlayer(String playerName, double amount) {
double balance;
try {
balance = MCCom.getExternalBalance(playerName);
} catch (NoAccountException e) {
MCCom.create(playerName);
balance = MCCom.getExternalBalance(playerName);
}
if(amount < 0.0D) {
return new EconomyResponse(0.0D, 0.0, ResponseType.FAILURE, "Cannot deposit negative funds");
}
balance += amount;
MCCom.setExternalBalance(playerName, balance);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
}
示例9: isBankMember
@Override
public EconomyResponse isBankMember (String name, String playerName) {
GroupBank groupBank = api.getGroupBank(name);
if (groupBank == null) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
}
Account account = api.getAccount(name);
if (account == null) {
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
}
if (groupBank.groupMembers.getMembers().containsKey(playerName)) {
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
}
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("NotAMemberOf"), groupBank.getName(), account.getName()));
}
示例10: 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");
}
}
示例11: depositPlayer
@Override
public EconomyResponse depositPlayer(OfflinePlayer arg0, double arg1) {
String accountNumber = UniversalAccounts.getInstance().getOrCreatePlayerAccount(arg0.getUniqueId().toString());
if (UniversalAccounts.getInstance().creditAccount(accountNumber, (int) arg1)) {
return new EconomyResponse(arg1, 0, ResponseType.SUCCESS, null);
}
return new EconomyResponse(arg1, 0, ResponseType.FAILURE, "Deposit failed.");
}
示例12: 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);
}
}
示例13: 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);
}
}
示例14: 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);
}
示例15: 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);
}