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


Java EconomyResponse.transactionSuccess方法代码示例

本文整理汇总了Java中net.milkbowl.vault.economy.EconomyResponse.transactionSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java EconomyResponse.transactionSuccess方法的具体用法?Java EconomyResponse.transactionSuccess怎么用?Java EconomyResponse.transactionSuccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.milkbowl.vault.economy.EconomyResponse的用法示例。


在下文中一共展示了EconomyResponse.transactionSuccess方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: onClick

import net.milkbowl.vault.economy.EconomyResponse; //导入方法依赖的package包/类
@Override
public void onClick(ItemClickEvent e)
{
    
    if(player.getInventory().firstEmpty() == -1 && !auctionDataManager.isVaultAvailable(player))
    {
        player.sendMessage(localeManager.getLocalizedString("ui.fullInventory"));
        player.sendMessage(localeManager.getLocalizedString("ui.fullVault"));
        return;
    }
    
    if(!auctionDataManager.hasBidBefore(player, lot))
    {
        EconomyResponse er = Main.economy.withdrawPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()), lot.getPrice());
        
        if(!er.transactionSuccess())
        {
            player.sendMessage(localeManager.getLocalizedString("ui.balanceNotEnough")
                    .replace("{balance}", String.valueOf(er.balance))
                    .replace("{currency}", Main.economy.currencyNamePlural()));
            return;
        }
    }
    
    auctionDataManager.bid(player, true, lot, 0);
    auctionDataManager.hammer(lot);
    openParentShowcase();
    
}
 
开发者ID:Cnly,项目名称:WowSuchCleaner,代码行数:30,代码来源:LotOperationMenu.java

示例8: onPlayerInteract

import net.milkbowl.vault.economy.EconomyResponse; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e){
    final Player player = e.getPlayer();
    
    ArrayList<String> testlore = new ArrayList<String>();
	testlore.add(Main.color("&7Right Click in the air to deposit this."));
	testlore.add(Main.color("&8[&bComputerSMP&8]"));
	
	
	if (e.getAction() != Action.RIGHT_CLICK_AIR) return;
	
	
    if (player.getItemInHand().getItemMeta().getLore().equals(testlore)) {
        if(e.getAction() == Action.RIGHT_CLICK_AIR){
            if(player.getItemInHand().getType() == Material.PAPER){       	
            		double depositamount = 0.0;
            		String plainMoney = player.getItemInHand().getItemMeta().getDisplayName().replace(Main.color("&4&l$"), " ");
            		ChatColor.stripColor(plainMoney);
            		depositamount = Double.parseDouble(plainMoney);
            		EconomyResponse r = Main.econ.depositPlayer(player, depositamount);
		            if(r.transactionSuccess()) {
		                player.sendMessage(String.format(Prefix + "Deposited %s and now you have %s", Main.econ.format(r.amount), Main.econ.format(r.balance))); 
		                ItemStack inHand = player.getItemInHand();
		              int amountInHand = inHand.getAmount();
		              if (amountInHand == 1) {
		            	  player.setItemInHand(new ItemStack(Material.AIR));
		              } else {
		              inHand.setAmount(--amountInHand);
		              }
		            } else {
		            	player.sendMessage(String.format(Prefix + Main.color("&4An error occured: %s"), r.errorMessage));    		             
		            }			
            	}
            }  
        }  
}
 
开发者ID:JustBru00,项目名称:ComputerSMPPlugin,代码行数:37,代码来源:GUIWatcher.java

示例9: onCommand

import net.milkbowl.vault.economy.EconomyResponse; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command,	String label, String[] args) {
	if (command.getName().equalsIgnoreCase("withdraw")) {
		if (sender instanceof Player) {
			if (args.length == 1) {
				Player player = (Player) sender;	
				double withdrawAmount = 0;
				try {
				    withdrawAmount = Double.parseDouble(args[0]);
				} catch(Exception e){
					sender.sendMessage(Main.Prefix + Main.color("&cPlease put a number."));
					return true;
				}
				EconomyResponse r = Main.econ.withdrawPlayer(player, withdrawAmount);
	            if(r.transactionSuccess()) {
	                player.sendMessage(String.format(Main.Prefix + "Withdrew %s and now you have %s", Main.econ.format(r.amount), Main.econ.format(r.balance)));
	                PlayerInventory pi = player.getInventory();
	                pi.addItem(Main.createPaperItem(Main.color("&4&l$" + args[0]), Main.color("&7Right Click in the air to deposit this."), Main.color("&8[&bComputerSMP&8]")));
	                
	                return true;		                
	            } else {
	                player.sendMessage(String.format(Main.Prefix + Main.color("&4An error occured: %s"), r.errorMessage));	
	                return true;
	            }			
			} else {
				sender.sendMessage(Main.Prefix + Main.color("&cToo Many or Too Little Args. Please only type one number after /withdraw. Eg: /withdraw 50"));
			}
		} else {
			sender.sendMessage(Main.Prefix + Main.color("&4Why JustBru00. Just Why.....  sender NOT instanceof Player"));
			return true;
		}
	}
	return false;
}
 
开发者ID:JustBru00,项目名称:ComputerSMPPlugin,代码行数:35,代码来源:Withdraw.java

示例10: buy

import net.milkbowl.vault.economy.EconomyResponse; //导入方法依赖的package包/类
/**
 * 給予玩家單一旗幟
 *
 * @param player 要給予物品的玩家
 * @param banner 要給予的旗幟
 * @return 是否成功給予
 */
public static boolean buy(Player player, ItemStack banner) {
    //檢查是否啟用經濟
    if (BannerMaker.getInstance().econ == null) {
        //未啟用經濟,強制失敗
        player.sendMessage(MessageUtil.format(true, "&cError: Economy not supported"));
        return false;
    }
    //價格
    Double price = EconUtil.getPrice(banner);
    //檢查財產是否足夠
    if (!BannerMaker.getInstance().econ.has(player, price)) {
        //財產不足
        player.sendMessage(MessageUtil.format(true, "&c" + tl("general.no-money")));
        return false;
    }
    //扣款
    EconomyResponse response = BannerMaker.getInstance().econ.withdrawPlayer(player, price);
    //檢查交易是否成功
    if (!response.transactionSuccess()) {
        //交易失敗
        player.sendMessage(MessageUtil.format(true, "&cError: " + response.errorMessage));
        return false;
    }
    InventoryUtil.give(player, banner);
    player.sendMessage(MessageUtil.format(true, "&a" + tl("general.money-transaction", BannerMaker.getInstance().econ.format(response.amount), BannerMaker.getInstance().econ.format(response.balance))));
    return true;
}
 
开发者ID:jyhsu2000,项目名称:BannerMaker,代码行数:35,代码来源:BannerUtil.java

示例11: deserialize

import net.milkbowl.vault.economy.EconomyResponse; //导入方法依赖的package包/类
/**
 * Deserialize all aspects of a player, and apply their data. See {@link PlayerSerializer#serialize(PWIPlayer)}
 * for an explanation of the data format number.
 *
 * @param data   The saved player information.
 * @param player The Player to apply the deserialized information to.
 */
public void deserialize(final JsonObject data, final Player player, DeserializeCause cause) {
    ConsoleLogger.debug("[SERIALIZER] Deserializing player '" + player.getName()+ "'");

    int format = 0;
    if (data.has("data-format"))
        format = data.get("data-format").getAsInt();

    if (settings.getProperty(PwiProperties.LOAD_ENDER_CHESTS) && data.has("ender-chest"))
        player.getEnderChest().setContents(inventorySerializer.deserializeInventory(data.getAsJsonArray("ender-chest"),
                player.getEnderChest().getSize(), format));
    if (settings.getProperty(PwiProperties.LOAD_INVENTORY) && data.has("inventory"))
        inventorySerializer.setInventory(player, data.getAsJsonObject("inventory"), format);
    if (data.has("stats"))
        statSerializer.deserialize(player, data.getAsJsonObject("stats"), format);
    if (plugin.isEconEnabled()) {
        Economy econ = plugin.getEconomy();
        if (econ == null) {
            ConsoleLogger.warning("Economy saving is turned on, but no economy found!");
            return;
        }

        ConsoleLogger.debug("[ECON] Withdrawing " + econ.getBalance(player) + " from '" + player.getName() + "'!");
        EconomyResponse er = econ.withdrawPlayer(player, econ.getBalance(player));
        if (!er.transactionSuccess()) {
            ConsoleLogger.warning("[ECON] Unable to withdraw funds from '" + player.getName() + "': " + er.errorMessage);
        }

        if (data.has("economy") && er.transactionSuccess()) {
            EconomySerializer.deserialize(econ, data.getAsJsonObject("economy"), player);
        }
    }

    ConsoleLogger.debug("[SERIALIZER] Done deserializing player '" + player.getName()+ "'");

    // Call event to signal loading is done
    InventoryLoadCompleteEvent event = new InventoryLoadCompleteEvent(player, cause);
    bukkitService.callEvent(event);
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:46,代码来源:PlayerSerializer.java

示例12: formatMsg

import net.milkbowl.vault.economy.EconomyResponse; //导入方法依赖的package包/类
/**
 * Formats the message with the {cost} and {error} varibles.
 * @param msg The message you want to replace the varibles in.
 * @param r The {@link EconomyResponse} that you want the varibles replace with.
 * @return The formated string with the variibles replaced.
 */
public static String formatMsg(String msg, EconomyResponse r) {		
	
	msg = msg.replace("{cost}", String.valueOf(r.amount));	
	
	if (!r.transactionSuccess()) msg = msg.replace("{error}", r.errorMessage);
	return msg;
}
 
开发者ID:JustBru00,项目名称:RenamePlugin,代码行数:14,代码来源:EconomyManager.java

示例13: onPlayerInteract

import net.milkbowl.vault.economy.EconomyResponse; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
   public void onPlayerInteract(PlayerInteractEvent e){
       final Player player = e.getPlayer();
       
       ArrayList<String> testlore = new ArrayList<String>();
   	testlore.add(Main.color("&7Right Click in the air to deposit this."));
   	testlore.add(Main.color(Main.Prefix));
   	
   	
   	if (e.getAction() != Action.RIGHT_CLICK_AIR) return;
   	
   	if (player.getItemInHand().getItemMeta().getLore() == null) return;
   	
       if (player.getItemInHand().getItemMeta().getLore().equals(testlore)) {
           if(e.getAction() == Action.RIGHT_CLICK_AIR){
               if(player.getItemInHand().getType() == Material.PAPER){       	
               		double depositamount = 0.0;
               		String plainMoney = player.getItemInHand().getItemMeta().getDisplayName().replace(Main.color("&4&l$"), " ");
               		ChatColor.stripColor(plainMoney);
               		depositamount = Double.parseDouble(plainMoney);
               		EconomyResponse r = Main.econ.depositPlayer(player, depositamount);
   		            if(r.transactionSuccess()) {
   		                player.sendMessage(String.format(Main.Prefix + "Deposited %s and now you have %s", Main.econ.format(r.amount), Main.econ.format(r.balance))); 
   		                ItemStack inHand = player.getItemInHand();
   		              int amountInHand = inHand.getAmount();
   		              if (amountInHand == 1) {
   		            	  player.setItemInHand(new ItemStack(Material.AIR));
   		              } else {
   		              inHand.setAmount(--amountInHand);
   		              }
   		            } else {
   		            	player.sendMessage(String.format(Main.Prefix + Main.color("&4An error occured: %s"), r.errorMessage));    		             
   		            }			
               	}
               }  
           }  
   }
 
开发者ID:JustBru00,项目名称:EpicSMP,代码行数:39,代码来源:Listener.java

示例14: onCommand

import net.milkbowl.vault.economy.EconomyResponse; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command command,	String label, String[] args) {
	if (command.getName().equalsIgnoreCase("withdraw")) {			
		if (sender instanceof Player) {
			if (args.length == 1) {
				Player player = (Player) sender;
				if (!player.hasPermission(main.getConfigString("commands.withdraw.permission"))) {
					player.sendMessage(main.getConfigString("plugin messages.no permission"));
					return true;
				}
				double withdrawAmount = 0;
				try {
				    withdrawAmount = Double.parseDouble(args[0]);
				} catch(Exception e){
					sender.sendMessage(Main.Prefix + main.getConfigString("commands.withdraw.use a number"));
					return true;
				}
				EconomyResponse r = Main.econ.withdrawPlayer(player, withdrawAmount);
	            if(r.transactionSuccess()) {
	                player.sendMessage(String.format(Main.Prefix + "Withdrew %s and now you have %s", Main.econ.format(r.amount), Main.econ.format(r.balance)));
	                PlayerInventory pi = player.getInventory();
	                pi.addItem(ItemMaker.createItemStack(Main.color("&4&l$" + args[0]), "PAPER", Main.color("&7Right Click in the air to deposit this."), Main.Prefix));
	                
	                return true;		                
	            } else {
	                player.sendMessage(String.format(Main.Prefix + Main.color("&4An error occured: %s"), r.errorMessage));	
	                return true;
	            }			
			} else {
				sender.sendMessage(Main.Prefix + main.getConfigString("commands.withdraw.too many or too little args"));
			}
		} else {
			sender.sendMessage(Main.Prefix + main.getConfigString("commands.withdraw.sender not player"));
			return true;
		}
	}
	return false;
}
 
开发者ID:JustBru00,项目名称:EpicSMP,代码行数:40,代码来源:Withdraw.java

示例15: withdrawPlayer

import net.milkbowl.vault.economy.EconomyResponse; //导入方法依赖的package包/类
public boolean withdrawPlayer(Player player, double amount) {
    if (economy == null || player == null) {
        return false;
    }
    EconomyResponse response  = economy.withdrawPlayer(player, amount);
    return response.transactionSuccess();
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:8,代码来源:VaultController.java


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