diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-03-13 16:15:01 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-03-13 16:15:01 +0000 |
commit | a0373a4eea070cc81f1852f1789d4368a28a4de8 (patch) | |
tree | 00a656d98e5ddfaaae4687fcce2ec8d4d3a5587a | |
parent | 09bc09c0db4887d922b7e4de7e8aec19bbbdc4be (diff) | |
download | Essentials-a0373a4eea070cc81f1852f1789d4368a28a4de8.tar Essentials-a0373a4eea070cc81f1852f1789d4368a28a4de8.tar.gz Essentials-a0373a4eea070cc81f1852f1789d4368a28a4de8.tar.lz Essentials-a0373a4eea070cc81f1852f1789d4368a28a4de8.tar.xz Essentials-a0373a4eea070cc81f1852f1789d4368a28a4de8.zip |
Fixing warp command costs.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Trade.java | 18 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandwarp.java | 5 |
2 files changed, 18 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Trade.java b/Essentials/src/com/earth2me/essentials/Trade.java index 3594c3137..fbdc471bd 100644 --- a/Essentials/src/com/earth2me/essentials/Trade.java +++ b/Essentials/src/com/earth2me/essentials/Trade.java @@ -158,11 +158,9 @@ public class Trade InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack()); user.updateInventory(); } - if (command != null && !command.isEmpty() - && !user.isAuthorized("essentials.nocommandcost.all") - && !user.isAuthorized("essentials.nocommandcost." + command)) + if (command != null) { - final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command); + final double cost = getCommandCost(user); if (!user.canAfford(cost) && cost > 0) { throw new ChargeException(_("notEnoughMoney")); @@ -194,6 +192,18 @@ public class Trade { return exp; } + + public Double getCommandCost(final IUser user) + { + double cost = 0d; + if (command != null && !command.isEmpty() + && !user.isAuthorized("essentials.nocommandcost.all") + && !user.isAuthorized("essentials.nocommandcost." + command)) + { + cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command); + } + return cost; + } private static FileWriter fw = null; public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index 62641172b..84df12900 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -115,7 +115,10 @@ public class Commandwarp extends EssentialsCommand private void warpUser(final User owner, final User user, final String name) throws Exception { - final Trade charge = new Trade("warp-" + name.toLowerCase(Locale.ENGLISH).replace('_', '-'), ess); + final Trade chargeWarp = new Trade("warp-" + name.toLowerCase(Locale.ENGLISH).replace('_', '-'), ess); + final Trade chargeCmd = new Trade(this.getName(), ess); + final double fullCharge = chargeWarp.getCommandCost(user) + chargeCmd.getCommandCost(user); + final Trade charge = new Trade(fullCharge, ess); charge.isAffordableFor(owner); if (ess.getSettings().getPerWarpPermission() && !owner.isAuthorized("essentials.warp." + name)) { |