• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Account类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.spongepowered.api.service.economy.account.Account的典型用法代码示例。如果您正苦于以下问题:Java Account类的具体用法?Java Account怎么用?Java Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Account类属于org.spongepowered.api.service.economy.account包,在下文中一共展示了Account类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: clanBankBalanceCommand

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
@Command(name = "balance", description = "Посмотреть баланс казны клана", isPlayerOnly = true, isClanOnly = true, spongePermission = "mcclans.user.bank.balance")
public void clanBankBalanceCommand(CommandSource sender, ClanPlayerImpl clanPlayer) {
    if (Config.getBoolean(Config.USE_ECONOMY)) {
        ClanImpl clan = clanPlayer.getClan();
        Currency currency = MCClans.getPlugin().getServiceHelper().currency;
        Optional<Account> accountOpt = MCClans.getPlugin().getServiceHelper().economyService.getOrCreateAccount(clan.getBankId());
        if (accountOpt.isPresent()) {
            Account account = accountOpt.get();
            BigDecimal balance = account.getBalance(currency);
            Messages.sendClanBankBalance(sender, balance.doubleValue(), currency.getDisplayName().toPlain());
        } else {
            Messages.sendWarningMessage(sender, Messages.NO_ECONOMY_ACCOUNT_FOUND);
        }
    } else {
        Messages.sendWarningMessage(sender, Messages.ECONOMY_USAGE_IS_CURRENTLY_DISABLED);
    }
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:18,代码来源:ClanBankCommands.java


示例2: getEconomyAccount

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
@Override
public Optional<Account> getEconomyAccount() {
    if (this.isAdminClaim() || this.isSubdivision() || !GriefPreventionPlugin.getGlobalConfig().getConfig().claim.bankTaxSystem) {
        return Optional.empty();
    }

    if (this.economyAccount != null) {
        return Optional.of(this.economyAccount);
    }
    EconomyService economyService = GriefPreventionPlugin.instance.economyService.orElse(null);
    if (economyService != null) {
        this.economyAccount = economyService.getOrCreateAccount(this.claimStorage.filePath.getFileName().toString()).orElse(null);
        return Optional.ofNullable(this.economyAccount);
    }
    return Optional.empty();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:17,代码来源:GPClaim.java


示例3: handleTownTax

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
private void handleTownTax(GPClaim town, GPPlayerData playerData) {
    Account townAccount = town.getEconomyAccount().orElse(null);
    if (townAccount == null) {
        // Virtual Accounts not supported by Economy Plugin so ignore
        return;
    }
    List<Claim> children = town.getChildren(true);
    for (Claim child : children) {
        // resident tax
        if (child.isBasicClaim()) {
            handleClaimTax((GPClaim) child, playerData, true);
        }
    }
    if (town.getOwnerUniqueId().equals(playerData.playerID)) {
        handleClaimTax(town, playerData, false);
    }
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:18,代码来源:TaxApplyTask.java


示例4: addFunds

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
private void addFunds(double amount, Player player) {
    String virt = JobsLite.getOption("virtual-draw");
    if (virt.equalsIgnoreCase("none")) {
        // Generate money
        account.deposit(JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                Cause.of(EventContext.empty(),(JobsLite.getInstance().container)));
    } else {
        // Transfer money
        Optional<Account> aOpt = JobsLite.getEconomyService().getOrCreateAccount(virt);
        if (aOpt.isPresent()) {
            if (!aOpt.get()
                    .transfer(account, JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                            Cause.of(EventContext.empty(),(JobsLite.getInstance().container))).getResult().equals(ResultType.SUCCESS)) {
                // Transfer failed
                if (!JobsLite.msgCache.contains(player.getUniqueId())) {
                    player.sendMessage(messageStorage.getMessage("working.nofunds"));
                    JobsLite.msgCache.add(player.getUniqueId());
                }
            }
        } else {
            // Failed to find account
            JobsLite.getInstance().logger.error("Failed to find virtual account! Payment will not be given!");
        }
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:26,代码来源:MobDeathListener.java


示例5: addFunds

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
private void addFunds(double amount, Player player) {
    String virt = JobsLite.getOption("virtual-draw");
    if (virt.equalsIgnoreCase("none")) {
        // Generate money
        account.deposit(JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                Cause.of(EventContext.empty(), JobsLite.getInstance().container));
    } else {
        // Transfer money
        Optional<Account> aOpt = JobsLite.getEconomyService().getOrCreateAccount(virt);
        if (aOpt.isPresent()) {
            if (!aOpt.get()
                    .transfer(account, JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                            Cause.of(EventContext.empty(),JobsLite.getInstance().container)).getResult().equals(ResultType.SUCCESS)) {
                // Transfer failed
                if (!JobsLite.msgCache.contains(player.getUniqueId())) {
                    player.sendMessage(messageStorage.getMessage("working.nofunds"));
                    JobsLite.msgCache.add(player.getUniqueId());
                }
            }
        } else {
            // Failed to find account
            JobsLite.getInstance().logger.error("Failed to find virtual account! Payment will not be given!");
        }
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:26,代码来源:PlayerPlaceBlockListener.java


示例6: addFunds

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
private void addFunds(double amount, Player player) {
    String virt = JobsLite.getOption("virtual-draw");
    if (virt.equalsIgnoreCase("none")) {
        // Generate money
        account.deposit(JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                Cause.of(EventContext.empty(), JobsLite.getInstance().container));
    } else {
        // Transfer money
        Optional<Account> aOpt = JobsLite.getEconomyService().getOrCreateAccount(virt);
        if (aOpt.isPresent()) {
            if (!aOpt.get()
                    .transfer(account, JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                            Cause.of(EventContext.empty(), JobsLite.getInstance().container)).getResult().equals(ResultType.SUCCESS)) {
                // Transfer failed
                if (!JobsLite.msgCache.contains(player.getUniqueId())) {
                    player.sendMessage(messageStorage.getMessage("working.nofunds"));
                    JobsLite.msgCache.add(player.getUniqueId());
                }
            }
        } else {
            // Failed to find account
            JobsLite.getInstance().logger.error("Failed to find virtual account! Payment will not be given!");
        }
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:26,代码来源:PlayerBlockBreakListener.java


示例7: run

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
@Override
public void run(Player src, CommandContext args) {
    if (args.getOne("target").isPresent() && args.getOne("amount").isPresent()) {
        String target = args.<String>getOne("target").get();
        BigDecimal amount = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<Account> aOpt = EconomyLite.getEconomyService().getOrCreateAccount(target);
        Optional<UniqueAccount> uOpt = EconomyLite.getEconomyService().getOrCreateAccount(src.getUniqueId());
        // Check for negative payments
        if (amount.doubleValue() <= 0) {
            src.sendMessage(messageStorage.getMessage("command.pay.invalid"));
        } else {
            if (aOpt.isPresent() && uOpt.isPresent()) {
                Account receiver = aOpt.get();
                UniqueAccount payer = uOpt.get();
                if (payer.transfer(receiver, ecoService.getDefaultCurrency(), amount, Cause.of(EventContext.empty(),(EconomyLite.getInstance())))
                        .getResult().equals(ResultType.SUCCESS)) {
                    src.sendMessage(messageStorage.getMessage("command.pay.success", "target", receiver.getDisplayName()));
                } else {
                    src.sendMessage(messageStorage.getMessage("command.pay.failed", "target", receiver.getDisplayName()));
                }
            }
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:27,代码来源:PayVirtualCommand.java


示例8: run

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    Currency currency = currencyService.getCurrentCurrency();
    if (args.getOne("account").isPresent()) {
        if (src.hasPermission("economylite.admin.virtualbalance")) {
            String target = args.<String>getOne("account").get();
            Optional<Account> aOpt = EconomyLite.getEconomyService().getOrCreateAccount(target);
            if (aOpt.isPresent()) {
                BigDecimal bal = aOpt.get().getBalance(currency);
                Text label = currency.getPluralDisplayName();
                if (bal.equals(BigDecimal.ONE)) {
                    label = currency.getDisplayName();
                }
                src.sendMessage(messageStorage.getMessage("command.balanceother",
                        ImmutableMap.of("player", aOpt.get().getDisplayName(), "balance", Text.of(String.format(Locale.ENGLISH, "%,.2f", bal)),
                                "label", label)));
            } else {
                src.sendMessage(messageStorage.getMessage("command.error"));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.noperm"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:27,代码来源:VirtualBalanceCommand.java


示例9: run

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("account").isPresent() && args.getOne("amount").isPresent()) {
        String target = args.<String>getOne("account").get();
        BigDecimal newBal = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<Account> aOpt = EconomyLite.getEconomyService().getOrCreateAccount(target);
        if (aOpt.isPresent()) {
            Account targetAccount = aOpt.get();
            if (targetAccount.setBalance(EconomyLite.getCurrencyService().getCurrentCurrency(), newBal,
                    Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) {
                src.sendMessage(messageStorage.getMessage("command.econ.setsuccess", "name", targetAccount.getDisplayName()));
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.setfail", "name", targetAccount.getDisplayName()));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:22,代码来源:VirtualSetCommand.java


示例10: run

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("account").isPresent() && args.getOne("amount").isPresent()) {
        String target = args.<String>getOne("account").get();
        BigDecimal toRemove = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<Account> aOpt = EconomyLite.getEconomyService().getOrCreateAccount(target);
        if (aOpt.isPresent()) {
            Account targetAccount = aOpt.get();
            if (targetAccount.withdraw(EconomyLite.getCurrencyService().getCurrentCurrency(), toRemove,
                    Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) {
                src.sendMessage(messageStorage.getMessage("command.econ.removesuccess", "name", target));
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.removefail", "name", target));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:22,代码来源:VirtualRemoveCommand.java


示例11: run

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("account").isPresent() && args.getOne("amount").isPresent()) {
        String target = args.<String>getOne("account").get();
        BigDecimal toAdd = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<Account> aOpt = EconomyLite.getEconomyService().getOrCreateAccount(target);
        if (aOpt.isPresent()) {
            Account targetAccount = aOpt.get();
            if (targetAccount.deposit(EconomyLite.getCurrencyService().getCurrentCurrency(), toAdd,
                    Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) {
                src.sendMessage(messageStorage.getMessage("command.econ.addsuccess", "name", target));
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.addfail", "name", target));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:22,代码来源:VirtualAddCommand.java


示例12: getOrCreateAccount

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
@Override
public Optional<Account> getOrCreateAccount(String id) {
    if (virtualService.accountExists(id, getDefaultCurrency(), CauseFactory.create("New account check"))) {
        // Return the account
        return Optional.of(new LiteVirtualAccount(id));
    } else {
        // Make a new account
        VirtualAccount account = new LiteVirtualAccount(id);
        if (virtualService.setBalance(id, account.getDefaultBalance(getDefaultCurrency()), getDefaultCurrency(),
                CauseFactory.create("Creating account"))) {
            return Optional.of(account);
        } else {
            return Optional.empty();
        }
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:17,代码来源:LiteEconomyService.java


示例13: transfer

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
@Override
public TransferResult transfer(Account to, Currency currency, BigDecimal amount, Cause cause, Set<Context> contexts) {
    BigDecimal newBal = to.getBalance(currency).add(amount);
    // Check if the new balance is in bounds
    if (newBal.compareTo(BigDecimal.ZERO) == -1 || newBal.compareTo(BigDecimal.valueOf(999999999)) == 1) {
        return resultAndEvent(this, amount, currency, ResultType.ACCOUNT_NO_SPACE, to, cause);
    }
    // Check if the account has enough funds
    if (amount.compareTo(getBalance(currency)) == 1) {
        return resultAndEvent(this, amount, currency, ResultType.ACCOUNT_NO_FUNDS, to, cause);
    }
    if (withdraw(currency, amount, cause).getResult().equals(ResultType.SUCCESS)
            && to.deposit(currency, amount, cause).getResult().equals(ResultType.SUCCESS)) {
        return resultAndEvent(this, amount, currency, ResultType.SUCCESS, to, cause);
    } else {
        return resultAndEvent(this, amount, currency, ResultType.FAILED, to, cause);
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:19,代码来源:LiteUniqueAccount.java


示例14: getTopAccounts

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
public List<VirtualAccount> getTopAccounts(int start, int end, Cause cause) {
    debug("virtcommon: Getting top accounts - " + cause.toString());
    int offset = start - 1;
    int limit = end - offset;
    ArrayList<VirtualAccount> accounts = new ArrayList<>();
    List<String> ids =
            manager.queryTypeList("id", String.class, "SELECT id FROM economylitevirts WHERE currency = ? ORDER BY balance DESC LIMIT ?, ?",
                    EconomyLite.getEconomyService().getDefaultCurrency().getId(), String.valueOf(offset), String.valueOf(limit));
    EconomyService ecoService = EconomyLite.getEconomyService();
    for (String id : ids) {
        Optional<Account> vOpt = ecoService.getOrCreateAccount(id);
        if (vOpt.isPresent() && (vOpt.get() instanceof VirtualAccount)) {
            accounts.add((VirtualAccount) vOpt.get());
        }
    }
    return accounts;
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:18,代码来源:VirtualServiceCommon.java


示例15: getOrCreateAccount

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
@Override
public Optional<Account> getOrCreateAccount(String identifier)
{
    try
    {
        return getOrCreateAccount(UUID.fromString(identifier)).map(Account.class::cast);
    }
    catch (IllegalArgumentException e)
    {
        Account account = accounts.get(identifier);
        if (account == null)
        {
            return loadAccount(identifier, true);
        }
        return Optional.of(account);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:18,代码来源:BankConomyService.java


示例16: loadAccount

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
protected Optional<Account> loadAccount(String name, boolean create)
{
    AccountModel model = loadModel(name);
    if (model == null)
    {
        if (!create)
        {
            return Optional.empty();
        }
        model = createModel(name);
    }
    Account account;
    if (model.isUUID())
    {
        account = new BaseAccount.Unique(this, model, db);
    }
    else
    {
        account = new BaseAccount.Virtual(this, model, db);
    }
    this.accounts.put(account.getIdentifier(), account);
    return Optional.of(account);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:24,代码来源:BankConomyService.java


示例17: transferToBank

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
public static boolean transferToBank(String clanBankIdentifier, UUID clanMember, double charge) {
    EconomyService economyService = MCClans.getPlugin().getServiceHelper().economyService;
    Currency currency = MCClans.getPlugin().getServiceHelper().currency;
    Optional<Account> clanAccountOpt = economyService.getOrCreateAccount(clanBankIdentifier);
    if (!clanAccountOpt.isPresent()) {
        return false;
    }
    Optional<UniqueAccount> memberAccountOpt = economyService.getOrCreateAccount(clanMember);
    if (!memberAccountOpt.isPresent()) {
        return false;
    }

    return transfer(memberAccountOpt.get(), clanAccountOpt.get(), currency, charge);
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:15,代码来源:EconomyUtils.java


示例18: transferFromBank

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
public static boolean transferFromBank(String clanBankIdentifier, UUID clanMember, double charge) {
    EconomyService economyService = MCClans.getPlugin().getServiceHelper().economyService;
    Currency currency = MCClans.getPlugin().getServiceHelper().currency;
    Optional<Account> clanAccountOpt = economyService.getOrCreateAccount(clanBankIdentifier);
    if (!clanAccountOpt.isPresent()) {
        return false;
    }
    Optional<UniqueAccount> memberAccountOpt = economyService.getOrCreateAccount(clanMember);
    if (!memberAccountOpt.isPresent()) {
        return false;
    }

    return transfer(clanAccountOpt.get(), memberAccountOpt.get(), currency, charge);
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:15,代码来源:EconomyUtils.java


示例19: transfer

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
private static boolean transfer(Account fromAccount, Account toAccount, Currency currency, double charge) {
    if (charge == 0) {
        return true;
    }

    TransactionResult result = fromAccount.transfer(
            toAccount,
            currency,
            BigDecimal.valueOf(charge),
            Cause.of(NamedCause.of("MCClans", MCClans.getPlugin()))
    );
    return (result.getResult().equals(ResultType.SUCCESS));
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:14,代码来源:EconomyUtils.java


示例20: ETransferResult

import org.spongepowered.api.service.economy.account.Account; //导入依赖的package包/类
public ETransferResult(final EPlugin<EverEconomy> plugin, final Account account, final Account accountTo, final Currency currency, final BigDecimal amount, 
		final Set<Context> contexts, final ResultType result, final TransactionType transaction){
	this.account = account;
	this.accountTo = accountTo;
	this.currency = currency;
	this.amount = amount;
	this.contexts = contexts;
	this.result = result;
	this.transaction = transaction;
	
	new ETransactionResult(plugin, account, currency, amount, contexts, result, TransactionTypes.WITHDRAW);
	new ETransactionResult(plugin, accountTo, currency, amount, contexts, result, TransactionTypes.DEPOSIT);
}
 
开发者ID:EverCraft,项目名称:EverEconomy,代码行数:14,代码来源:ETransferResult.java



注:本文中的org.spongepowered.api.service.economy.account.Account类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ComboBoxAction类代码示例发布时间:2022-05-22
下一篇:
Java Bind类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap