summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-02-13 17:09:07 +0000
committerKHobbits <rob@khobbits.co.uk>2012-02-13 17:09:07 +0000
commit2699e02f96e7ab989bf518685eac3408ecfcde8c (patch)
tree26ea628a2e57a0f1bda5f7f932cb11b2843f714c
parent2d56de1483a8dbd75cba146fae4a0dbe4270b1e3 (diff)
downloadEssentials-2699e02f96e7ab989bf518685eac3408ecfcde8c.tar
Essentials-2699e02f96e7ab989bf518685eac3408ecfcde8c.tar.gz
Essentials-2699e02f96e7ab989bf518685eac3408ecfcde8c.tar.lz
Essentials-2699e02f96e7ab989bf518685eac3408ecfcde8c.tar.xz
Essentials-2699e02f96e7ab989bf518685eac3408ecfcde8c.zip
Add per warp command costs
Make warp other commands charge the commander, not the warped.
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandwarp.java20
1 files changed, 8 insertions, 12 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
index 51b64563b..62641172b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
@@ -8,6 +8,7 @@ import com.earth2me.essentials.Warps;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -44,10 +45,10 @@ public class Commandwarp extends EssentialsCommand
{
throw new Exception(_("playerNotFound"));
}
- warpUser(otherUser, args[0]);
+ warpUser(user, otherUser, args[0]);
throw new NoChargeException();
}
- warpUser(user, args[0]);
+ warpUser(user, user, args[0]);
throw new NoChargeException();
}
}
@@ -65,7 +66,7 @@ public class Commandwarp extends EssentialsCommand
{
throw new Exception(_("playerNotFound"));
}
- warpUser(otherUser, args[0]);
+ otherUser.getTeleport().warp(args[0], null, TeleportCause.COMMAND);
throw new NoChargeException();
}
@@ -112,17 +113,12 @@ public class Commandwarp extends EssentialsCommand
}
}
- private void warpUser(final User user, final String name) throws Exception
+ private void warpUser(final User owner, final User user, final String name) throws Exception
{
- final Trade charge = new Trade(this.getName(), ess);
- charge.isAffordableFor(user);
- if (ess.getSettings().getPerWarpPermission())
+ final Trade charge = new Trade("warp-" + name.toLowerCase(Locale.ENGLISH).replace('_', '-'), ess);
+ charge.isAffordableFor(owner);
+ if (ess.getSettings().getPerWarpPermission() && !owner.isAuthorized("essentials.warp." + name))
{
- if (user.isAuthorized("essentials.warp." + name))
- {
- user.getTeleport().warp(name, charge, TeleportCause.COMMAND);
- return;
- }
throw new Exception(_("warpUsePermission"));
}
user.getTeleport().warp(name, charge, TeleportCause.COMMAND);