當前位置: 首頁>>代碼示例>>Java>>正文


Java EconomyResponse類代碼示例

本文整理匯總了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;
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:20,代碼來源:ConfigIcon.java

示例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");
	}
}
 
開發者ID:HimaJyun,項目名稱:Jecon,代碼行數:17,代碼來源:VaultEconomy.java

示例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;
        }
    }
}
 
開發者ID:jolbol1,項目名稱:RandomCoordinatesV2,代碼行數:23,代碼來源:CoordinatesManager.java

示例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;
        }
    }
}
 
開發者ID:jolbol1,項目名稱:RandomCoordinatesV2,代碼行數:23,代碼來源:Coordinates.java

示例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);
}
 
開發者ID:notabadminer,項目名稱:UniversalCoinsVaultPlugin,代碼行數:18,代碼來源:UCEconomy.java

示例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;
}
 
開發者ID:NoChanceSD,項目名稱:AncientGates,代碼行數:23,代碼來源:Plugin.java

示例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();
	}
}
 
開發者ID:dmulloy2,項目名稱:SwornAPI,代碼行數:26,代碼來源:VaultHandler.java

示例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();
	}
}
 
開發者ID:dmulloy2,項目名稱:SwornAPI,代碼行數:26,代碼來源:VaultHandler.java

示例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));
}
 
開發者ID:Drewpercraft,項目名稱:BlockBank,代碼行數:23,代碼來源:VaultEconomy.java

示例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.");
}
 
開發者ID:Skyost,項目名稱:Skyowallet,代碼行數:18,代碼來源:VaultHook.java

示例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.");
}
 
開發者ID:Skyost,項目名稱:Skyowallet,代碼行數:18,代碼來源:VaultHook.java

示例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;
}
 
開發者ID:cjburkey01,項目名稱:ClaimChunk,代碼行數:8,代碼來源:Econ.java

示例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;
}
 
開發者ID:cjburkey01,項目名稱:ClaimChunk,代碼行數:8,代碼來源:Econ.java

示例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");
	}
}
 
開發者ID:HimaJyun,項目名稱:Jecon,代碼行數:15,代碼來源:VaultEconomy.java

示例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
    ));
}
 
開發者ID:AppleDash,項目名稱:SaneEconomy,代碼行數:11,代碼來源:EconomySaneEconomy.java


注:本文中的net.milkbowl.vault.economy.EconomyResponse類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。