public boolean pay(Player p) { if (!plugin.useVault) { return true; } Economy econ; RegisteredServiceProvider<Economy> rsp = plugin.getServer().getServicesManager().getRegistration(Economy.class); if (rsp == null) { return true; // No Vault found } econ = rsp.getProvider(); if (econ == null) { return true; // No Vault found } int money = plugin.warpCreatePrice; if (money == 0) { return true; } if (!econ.has(p.getName(), money)) { p.sendMessage("You do not have enough money! You need " + econ.format(money) + "!"); return false; } econ.withdrawPlayer(p.getName(), money); p.sendMessage("Withdrawing " + econ.format(money) + " from your account!"); return true; }
@Override public boolean execute() throws MissingOrIncorrectArgumentException, InsufficientPermissionException { if (errorCheck()) return true; // /xp price <amount|bank|me> String name = player.getName().toLowerCase(); // int currentXP = player.getTotalExperience(); int currentXP = Utilities.getTotalExp(player); int bankXP = XPBank.getBank().getBalance(name); int xp; EconomyResponse er; // Parse arguments if (args[1].equalsIgnoreCase("me")) xp = currentXP; else if (args[1].equalsIgnoreCase("bank")) xp = bankXP; else { try { xp = Integer.parseInt(args[1]); } catch (NumberFormatException nfe) { throw new MissingOrIncorrectArgumentException(); } } double dPrice = Properties.flatFeeDeposit + (Properties.perXPDeposit * xp); double wPrice = Properties.flatFeeWithdrawl + (Properties.perXPWithdrawl * xp); Messaging.send( player, "`pIt would cost `w" + economy.format(dPrice) + "`p to deposit `w" + xp + "`p XP."); Messaging.send( player, "`pIt would cost `w" + economy.format(wPrice) + "`p to withdraw `w" + xp + "`p XP."); return true; }
@Override public String format(double money) { return economy.format(money); }