本文整理汇总了Java中org.spongepowered.api.service.economy.account.Account类的典型用法代码示例。如果您正苦于以下问题:Java Account类的具体用法?Java Account怎么用?Java Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Account类属于org.spongepowered.api.service.economy.account包,在下文中一共展示了Account类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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();
}
示例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);
}
}
示例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!");
}
}
}
示例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!");
}
}
}
示例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!");
}
}
}
示例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"));
}
}
示例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"));
}
}
示例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"));
}
}
示例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"));
}
}
示例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"));
}
}
示例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();
}
}
}
示例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);
}
}
示例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;
}
示例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);
}
}