本文整理汇总了Java中net.milkbowl.vault.economy.EconomyResponse类的典型用法代码示例。如果您正苦于以下问题:Java EconomyResponse类的具体用法?Java EconomyResponse怎么用?Java EconomyResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EconomyResponse类属于net.milkbowl.vault.economy包,在下文中一共展示了EconomyResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pay
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
public boolean pay(Player player) {
double c = cost.resolve(player);
if (c > 0) {
Economy eco = EconomyManager.getEconomy();
if (eco == null) {
Uppercore.logger().severe("Cannot use economy: vault not found!");
return true;
}
EconomyResponse res = eco.withdrawPlayer(player, c);
if (!res.transactionSuccess()) {
noMoneyError.send(player);
if (noMoneySound != null)
noPermissionSound.play(player);
Uppercore.logger().log(Level.INFO, res.errorMessage);
return false;
} else return true;
}
return true;
}
示例2: withdrawPlayer
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
@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");
}
}
示例3: chargePlayer
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
/**
* Charge the player for the cost of teleporting.
* @param p The player we are taking money from.
* @param cost The cost of teleporting
* @return True if they have paid. False if they cannot pay.
*/
public boolean chargePlayer(final Player p, final double cost) {
if (!RandomCoords.getPlugin().setupEconomy() || cost == 0) {
return true;
} else {
final EconomyResponse r = RandomCoords.getPlugin().econ.withdrawPlayer(p, cost);
if (r.transactionSuccess()) {
messages.charged(p, cost);
return true;
} else {
messages.cost(p, cost);
return false;
}
}
}
示例4: hasPayed
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
/**
* Check if the player has paid the price of teleporting.
* @param p The initiater of the teleport, and who we're charging
* @param cost The cost
* @return True or False, Have they paid.
*/
public boolean hasPayed(final Player p, final double cost) {
if (!RandomCoords.getPlugin().setupEconomy() || cost == 0) {
return true;
} else {
final EconomyResponse r = RandomCoords.getPlugin().econ.withdrawPlayer(p, cost);
if (r.transactionSuccess()) {
messages.charged(p, cost);
return true;
} else {
messages.cost(p, cost);
return false;
}
}
}
示例5: withdrawPlayer
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
@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);
}
示例6: handleEconManage
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static boolean handleEconManage(final CommandSender sender, final Double requiredCost) {
if (!(sender instanceof Player))
return true;
final Player player = (Player) sender;
if (econ == null || !Conf.useEconomy || hasPermManage(sender, "ancientgates.econbypass") || requiredCost == 0.00) {
return true;
}
final Double balance = econ.getBalance(player.getName());
if (requiredCost <= balance) {
final EconomyResponse r = econ.withdrawPlayer(player.getName(), requiredCost);
if (r.transactionSuccess()) {
sender.sendMessage(String.format("You were charged %s and now have %s.", econ.format(r.amount), econ.format(r.balance)));
return true;
}
sender.sendMessage(String.format("An error occured: %s.", r.errorMessage));
return false;
}
return false;
}
示例7: deposit
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
/**
* Attempts to deposit a given amount into a given account's balance. Returns
* null if the transaction was a success.
*
* @param account Account to give money to
* @param amount Amount to give
* @return Error message, if applicable
*/
public String deposit(String account, double amount)
{
if (econ == null)
return "Economy is disabled.";
try
{
@SuppressWarnings("deprecation")
EconomyResponse response = econ.depositPlayer(account, amount);
return response.transactionSuccess() ? null : response.errorMessage;
}
catch (Throwable ex)
{
handler.getLogHandler().debug(Level.WARNING, Util.getUsefulStack(ex, "deposit({0}, {1})", account, amount));
return ex.toString();
}
}
示例8: withdraw
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
/**
* Attempts to withdraw a given amount from a given account's balance.
* Returns null if the transaction was a success.
*
* @param account Account to take money from
* @param amount Amount to take
* @return Error message, if applicable
*/
public String withdraw(String account, double amount)
{
if (econ == null)
return "Economy is disabled.";
try
{
@SuppressWarnings("deprecation")
EconomyResponse response = econ.withdrawPlayer(account, amount);
return response.transactionSuccess() ? null : response.errorMessage;
}
catch (Throwable ex)
{
handler.getLogHandler().debug(Level.WARNING, Util.getUsefulStack(ex, "withdraw({0}, {1})", account, amount));
return ex.toString();
}
}
示例9: withdrawPlayer
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
@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));
}
示例10: withdrawPlayer
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
@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.");
}
示例11: createBank
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
@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.");
}
示例12: addMoney
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
public EconomyResponse addMoney(UUID player, double amt) {
Player ply = getPlayer(player);
if (ply != null) {
return econ.depositPlayer(ply, Math.abs(amt));
}
return null;
}
示例13: takeMoney
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
public EconomyResponse takeMoney(UUID player, double amt) {
Player ply = getPlayer(player);
if (ply != null) {
return econ.withdrawPlayer(ply, Math.abs(amt));
}
return null;
}
示例14: depositPlayer
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
@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");
}
}
示例15: withdrawPlayer
import net.milkbowl.vault.economy.EconomyResponse; //导入依赖的package包/类
@Override
public EconomyResponse withdrawPlayer(String target, double amount) {
if (amount == 0) {
return new EconomyResponse(amount, getBalance(target), EconomyResponse.ResponseType.SUCCESS, "");
}
return transact(new Transaction(
makeEconomable(target), Economable.PLUGIN, amount, TransactionReason.PLUGIN_TAKE
));
}