Fixing warp command costs.

This commit is contained in:
KHobbits 2012-03-13 16:15:01 +00:00
parent dfd63a81ac
commit 267495a406
2 changed files with 18 additions and 5 deletions

View File

@ -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)

View File

@ -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))
{