本文整理汇总了Java中org.spongepowered.api.service.economy.transaction.ResultType类的典型用法代码示例。如果您正苦于以下问题:Java ResultType类的具体用法?Java ResultType怎么用?Java ResultType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResultType类属于org.spongepowered.api.service.economy.transaction包,在下文中一共展示了ResultType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: withdraw
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的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));
}
示例2: buyShop
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的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);
}
}
示例3: trigger
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的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;
}
示例4: trigger
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的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;
}
示例5: trigger
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的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;
}
示例6: trigger
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的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;
}
示例7: setBalance
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的package包/类
@Override
public TransactionResult setBalance(final Currency currency, final BigDecimal after, final Cause cause, final Set<Context> contexts) {
TransactionType transaction = TransactionTypes.WITHDRAW;
BigDecimal before = this.getBalance(currency);
BigDecimal amount = before.subtract(after);
// Si le changement est supérieur ou égal à 0 c'est que l'on dépose de l'argent
if (amount.compareTo(BigDecimal.ZERO) >= 0) {
transaction = TransactionTypes.DEPOSIT;
}
// Transfére
this.setBalance(currency, after);
this.log(currency, before, after, transaction, cause);
return new ETransactionResult(this.plugin, this, currency, amount.abs(), contexts, ResultType.SUCCESS, transaction);
}
示例8: resetBalances
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的package包/类
@Override
public Map<Currency, TransactionResult> resetBalances(final Cause cause, final Set<Context> contexts) {
Map<Currency, TransactionResult> list = new HashMap<Currency, TransactionResult>();
// Pour tous les monnaies
for (Currency currency : this.currencies.keySet()){
TransactionType transaction = TransactionTypes.WITHDRAW;
BigDecimal before = this.getBalance(currency);
BigDecimal after = getDefaultBalance(currency);
BigDecimal amount = before.subtract(after);
// Si le changement est supérieur ou égal à 0 c'est que l'on dépose de l'argent
if (amount.compareTo(BigDecimal.ZERO) >= 0) {
transaction = TransactionTypes.DEPOSIT;
}
// Transfére
this.setBalance(currency, after);
this.log(currency, before, after, transaction, cause);
list.put(currency, new ETransactionResult(this.plugin, this, currency, amount.abs(), contexts, ResultType.SUCCESS, transaction));
}
this.plugin.getThreadAsync().execute(() -> this.delete());
return list;
}
示例9: resetBalance
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的package包/类
@Override
public TransactionResult resetBalance(final Currency currency, final Cause cause, final Set<Context> contexts) {
TransactionType transaction = TransactionTypes.WITHDRAW;
BigDecimal before = this.getBalance(currency);
BigDecimal after = getDefaultBalance(currency);
BigDecimal amount = before.subtract(after);
// Si le changement est supérieur ou égal à 0 c'est que l'on dépose de l'argent
if (amount.compareTo(BigDecimal.ZERO) >= 0) {
transaction = TransactionTypes.DEPOSIT;
}
// Transfére
this.setBalance(currency, after);
this.log(currency, before, after, transaction, cause);
return new ETransactionResult(this.plugin, this, currency, amount.abs(), contexts, ResultType.SUCCESS, transaction);
}
示例10: deposit
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的package包/类
@Override
public TransactionResult deposit(final Currency currency, final BigDecimal amount, final Cause cause, final Set<Context> contexts) {
BigDecimal before = this.getBalance(currency);
BigDecimal after = before.add(amount);
// Quantité positive
if (amount.compareTo(BigDecimal.ZERO) >= 0) {
// Inférieur au max
if (after.compareTo(ECurrency.getBalanceMax(currency)) <= 0) {
// Transfére
this.setBalance(currency, after);
this.log(currency, before, after, TransactionTypes.DEPOSIT, cause);
return new ETransactionResult(this.plugin, this, currency, amount, contexts, ResultType.SUCCESS, TransactionTypes.DEPOSIT);
}
return new ETransactionResult(this.plugin, this, currency, amount, contexts, ResultType.ACCOUNT_NO_SPACE, TransactionTypes.DEPOSIT);
}
return new ETransactionResult(this.plugin, this, currency, amount, contexts, ResultType.FAILED, TransactionTypes.DEPOSIT);
}
示例11: withdraw
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的package包/类
@Override
public TransactionResult withdraw(final Currency currency, final BigDecimal amount, final Cause cause, final Set<Context> contexts) {
BigDecimal before = this.getBalance(currency);
BigDecimal after = before.subtract(amount);
// Quantité positive
if (amount.compareTo(BigDecimal.ZERO) >= 0) {
// Séperieur au min
if (after.compareTo(ECurrency.getBalanceMin(currency)) >= 0) {
// Transfére
this.setBalance(currency, after);
this.log(currency, before, after, TransactionTypes.WITHDRAW, cause);
return new ETransactionResult(this.plugin, this, currency, amount, contexts, ResultType.SUCCESS, TransactionTypes.WITHDRAW);
}
return new ETransactionResult(this.plugin, this, currency, amount, contexts, ResultType.ACCOUNT_NO_FUNDS, TransactionTypes.WITHDRAW);
}
return new ETransactionResult(this.plugin, this, currency, amount, contexts, ResultType.FAILED, TransactionTypes.WITHDRAW);
}
示例12: addFunds
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的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!");
}
}
}
示例13: addFunds
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的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!");
}
}
}
示例14: addFunds
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的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!");
}
}
}
示例15: run
import org.spongepowered.api.service.economy.transaction.ResultType; //导入依赖的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"));
}
}