当前位置: 首页>>代码示例>>Java>>正文


Java UniqueAccount类代码示例

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


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

示例1: withdraw

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
public static boolean withdraw(UUID uuid, double charge) {
    if (charge == 0) {
        return true;
    }

    EconomyService economyService = MCClans.getPlugin().getServiceHelper().economyService;
    Currency currency = MCClans.getPlugin().getServiceHelper().currency;
    Optional<UniqueAccount> accountOpt = economyService.getOrCreateAccount(uuid);
    if (!accountOpt.isPresent()) {
        return false;
    }

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

示例2: buyShop

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
public ShopTransactionResult buyShop(Player player) {

        if (!isForSale()) {
            return new ShopTransactionResult(Messages.THIS_SHOP_IS_NOT_FOR_SALE);
        }

        // Transfer funds from the purchaser to the owner
        EconManager manager = EconManager.getInstance();
        Optional<UniqueAccount> playerAccountOptional = manager.getOrCreateAccount(player.getUniqueId());
        Optional<UniqueAccount> ownerAccountOptional = manager.getOrCreateAccount(ownerUUID);

        TransactionResult result =
                playerAccountOptional.get()
                        .transfer(ownerAccountOptional.get(), getShopCurrency(), BigDecimal.valueOf(price), Sponge.getCauseStackManager().getCurrentCause());

        if(result.getResult() == ResultType.SUCCESS) {
            ownerUUID = player.getUniqueId();
            price = -1;
            rent = -1;
            managerUUIDset.clear();
            return ShopTransactionResult.SUCCESS;
        } else {
            return new ShopTransactionResult(Messages.YOU_DON_T_HAVE_ENOUGH_FUNDS);
        }
    }
 
开发者ID:Zerthick,项目名称:PlayerShopsRPG,代码行数:26,代码来源:Shop.java

示例3: rentExpire

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
public void rentExpire(boolean transferFunds, boolean clearItems) {
    managerUUIDset.clear();

    //Transfer shop's balance to renter on rent expire
    if (transferFunds) {
        EconManager manager = EconManager.getInstance();
        Optional<UniqueAccount> renterAccountOptional = manager.getOrCreateAccount(renterUUID);
        Optional<UniqueAccount> shopAccountOptional = manager.getOrCreateAccount(getUUID());

        if (renterAccountOptional.isPresent() && shopAccountOptional.isPresent()) {
            UniqueAccount renterAccount = renterAccountOptional.get();
            UniqueAccount shopAccount = shopAccountOptional.get();

            shopAccount.transfer(renterAccount,
                    getShopCurrency(),
                    shopAccount.getBalance(getShopCurrency()),
                    Sponge.getCauseStackManager().getCurrentCause());
        }
    }

    if (clearItems) {
        items.clear();
    }

    renterUUID = null;
}
 
开发者ID:Zerthick,项目名称:PlayerShopsRPG,代码行数:27,代码来源:Shop.java

示例4: depositFunds

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
public ShopTransactionResult depositFunds(Player player, BigDecimal amount) {
    //If the player is not the owner of the shop return a message to the player
    if (!hasRenterPermissions(player)) {
        return new ShopTransactionResult(Messages.YOU_ARE_NOT_THE_OWNER_OF_THIS_SHOP);
    }
    EconManager manager = EconManager.getInstance();

    Optional<UniqueAccount> playerAccountOptional = manager.getOrCreateAccount(player.getUniqueId());
    Optional<UniqueAccount> shopAccountOptional = manager.getOrCreateAccount(getUUID());

    if (playerAccountOptional.isPresent() && shopAccountOptional.isPresent()) {
        shopAccountOptional.get().transfer(playerAccountOptional.get(), getShopCurrency(), amount, Sponge.getCauseStackManager().getCurrentCause());
    }

    return ShopTransactionResult.SUCCESS;
}
 
开发者ID:Zerthick,项目名称:PlayerShopsRPG,代码行数:17,代码来源:Shop.java

示例5: withdrawFunds

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
public ShopTransactionResult withdrawFunds(Player player, BigDecimal amount) {
    //If the player is not the owner of the shop return a message to the player
    if (!hasRenterPermissions(player)) {
        return new ShopTransactionResult(Messages.YOU_ARE_NOT_THE_OWNER_OF_THIS_SHOP);
    }
    EconManager manager = EconManager.getInstance();

    Optional<UniqueAccount> playerAccountOptional = manager.getOrCreateAccount(player.getUniqueId());
    Optional<UniqueAccount> shopAccountOptional = manager.getOrCreateAccount(getUUID());

    if (playerAccountOptional.isPresent() && shopAccountOptional.isPresent()) {
        playerAccountOptional.get().transfer(shopAccountOptional.get(), getShopCurrency(), amount, Sponge.getCauseStackManager().getCurrentCause());
    }

    return ShopTransactionResult.SUCCESS;
}
 
开发者ID:Zerthick,项目名称:PlayerShopsRPG,代码行数:17,代码来源:Shop.java

示例6: trigger

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
@Override
public boolean trigger(Player player) {
	if (CarrotShop.getEcoService() != null) {
		UniqueAccount buyerAccount = CarrotShop.getEcoService().getOrCreateAccount(player.getUniqueId()).get();
		TransactionResult result = buyerAccount.withdraw(getCurrency(), BigDecimal.valueOf(price), CarrotShop.getCause());
		if (result.getResult() != ResultType.SUCCESS) {
			player.sendMessage(Text.of(TextColors.DARK_RED, "You don't have enough money!"));
			return false;
		}
		player.sendMessage(Text.of("Device deactivated for ", formatPrice(price)));
	} else {
		player.sendMessage(Text.of("Device deactivated"));
	}

	lever.offer(Keys.POWERED, false, CarrotShop.getCause());

	return true;
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:19,代码来源:DeviceOff.java

示例7: trigger

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
@Override
public boolean trigger(Player player) {
	if (CarrotShop.getEcoService() != null) {
		UniqueAccount buyerAccount = CarrotShop.getEcoService().getOrCreateAccount(player.getUniqueId()).get();
		TransactionResult result = buyerAccount.withdraw(getCurrency(), BigDecimal.valueOf(price), CarrotShop.getCause());
		if (result.getResult() != ResultType.SUCCESS) {
			player.sendMessage(Text.of(TextColors.DARK_RED, "You don't have enough money!"));
			return false;
		}
		player.sendMessage(Text.of("You healed for ", formatPrice(price)));
	}
	else
		player.sendMessage(Text.of("You healed"));

	player.offer(Keys.HEALTH, player.get(Keys.MAX_HEALTH).get());

	return true;
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:19,代码来源:Heal.java

示例8: trigger

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
@Override
public boolean trigger(Player player) {
	UniqueAccount buyerAccount = CarrotShop.getEcoService().getOrCreateAccount(player.getUniqueId()).get();
	TransactionResult result = buyerAccount.withdraw(getCurrency(), BigDecimal.valueOf(price), CarrotShop.getCause());
	if (result.getResult() != ResultType.SUCCESS) {
		player.sendMessage(Text.of(TextColors.DARK_RED, "You don't have enough money!"));
		return false;
	}
	Inventory inv = player.getInventory().query(InventoryRow.class);

	Builder itemsName = Text.builder();
	for (Inventory item : itemsTemplate.slots()) {
		if (item.peek().isPresent()) {
			itemsName.append(Text.of(TextColors.YELLOW, " ", item.peek().get().getTranslation().get(), " x", item.peek().get().getQuantity()));
			inv.offer(item.peek().get().copy()).getRejectedItems().forEach(action -> {
				putItemInWorld(action, player.getLocation());
			});
		}
	}

	ShopsLogs.log(getOwner(), player, "buy", super.getLocation(), Optional.of(price), getRawCurrency(), Optional.of(itemsTemplate), Optional.empty());
	
	player.sendMessage(Text.of("You bought", itemsName.build(), " for ", formatPrice(price)));

	return true;
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:27,代码来源:iBuy.java

示例9: trigger

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
@Override
public boolean trigger(Player player) {
	if (CarrotShop.getEcoService() != null) {
		UniqueAccount buyerAccount = CarrotShop.getEcoService().getOrCreateAccount(player.getUniqueId()).get();
		TransactionResult result = buyerAccount.withdraw(getCurrency(), BigDecimal.valueOf(price), CarrotShop.getCause());
		if (result.getResult() != ResultType.SUCCESS) {
			player.sendMessage(Text.of(TextColors.DARK_RED, "You don't have enough money!"));
			return false;
		}
		player.sendMessage(Text.of("Device activated for ", formatPrice(price)));
	} else {
		player.sendMessage(Text.of("Device activated"));
	}

	lever.offer(Keys.POWERED, true, CarrotShop.getCause());



	return true;
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:21,代码来源:DeviceOn.java

示例10: executeBalanceOthers

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
public CompletableFuture<Boolean> executeBalanceOthers(final CommandSource staff, final User user) {
	// La source et le joueur sont différent
	if (!user.getIdentifier().equals(staff.getIdentifier()) || !(staff instanceof EPlayer)){
		Optional<UniqueAccount> account = this.plugin.getService().getOrCreateAccount(user.getUniqueId());
		// Le compte existe
		if (account.isPresent()) {
			BigDecimal balance = account.get().getBalance(this.plugin.getService().getDefaultCurrency());
			EEMessages.BALANCE_OTHERS.sender()
				.replace(this.plugin.getService().getReplaces())
				.replace("{player}", () -> user.getName())
				.replace("{solde}", () -> this.plugin.getService().getDefaultCurrency().cast(balance))
				.replace("{solde_format}", () -> this.plugin.getService().getDefaultCurrency().format(balance))
				.sendTo(staff);
			return CompletableFuture.completedFuture(true);
		// Le compte est introuvable
		} else {
			EAMessages.ACCOUNT_NOT_FOUND.sender()
				.prefix(EEMessages.PREFIX)
				.sendTo(staff);
		}
	// La source et le joueur sont identique
	} else {
		return this.executeBalance((EPlayer) staff);
	}
	return CompletableFuture.completedFuture(false);
}
 
开发者ID:EverCraft,项目名称:EverEconomy,代码行数:27,代码来源:EEBalance.java

示例11: run

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("player").isPresent() && args.getOne("amount").isPresent()) {
        User target = args.<User>getOne("player").get();
        String targetName = target.getName();
        BigDecimal toRemove = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<UniqueAccount> uOpt = EconomyLite.getEconomyService().getOrCreateAccount(target.getUniqueId());
        if (uOpt.isPresent()) {
            UniqueAccount targetAccount = uOpt.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", targetName));
                attemptNotify(target);
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.removefail", "name", targetName));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:24,代码来源:RemoveCommand.java

示例12: run

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("player").isPresent() && args.getOne("balance").isPresent()) {
        User target = args.<User>getOne("player").get();
        String targetName = target.getName();
        BigDecimal newBal = BigDecimal.valueOf(args.<Double>getOne("balance").get());
        Optional<UniqueAccount> uOpt = EconomyLite.getEconomyService().getOrCreateAccount(target.getUniqueId());
        if (uOpt.isPresent()) {
            UniqueAccount targetAccount = uOpt.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", targetName));
                attemptNotify(target);
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.setfail", "name", targetName));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:24,代码来源:SetCommand.java

示例13: run

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("player").isPresent() && args.getOne("amount").isPresent()) {
        User target = args.<User>getOne("player").get();
        String targetName = target.getName();
        BigDecimal toAdd = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<UniqueAccount> uOpt = EconomyLite.getEconomyService().getOrCreateAccount(target.getUniqueId());
        if (uOpt.isPresent()) {
            UniqueAccount targetAccount = uOpt.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", targetName));
                attemptNotify(target);
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.addfail", "name", targetName));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:24,代码来源:AddCommand.java

示例14: run

import org.spongepowered.api.service.economy.account.UniqueAccount; //导入依赖的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

示例15: getTopAccounts

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


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