summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
diff options
context:
space:
mode:
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandwarp.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandwarp.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
new file mode 100644
index 000000000..c5471f831
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
@@ -0,0 +1,74 @@
+package com.earth2me.essentials.commands;
+
+import org.bukkit.Server;
+import com.earth2me.essentials.Essentials;
+import com.earth2me.essentials.User;
+import com.earth2me.essentials.Warps;
+
+
+public class Commandwarp extends EssentialsCommand
+{
+ public Commandwarp()
+ {
+ super("warp");
+ }
+
+ @Override
+ public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
+ {
+ boolean perWarpPermission = Essentials.getSettings().getPerWarpPermission();
+ if (args.length == 0) {
+ if (!user.isAuthorized("essentials.warp.list"))
+ {
+ user.sendMessage("§cYou do not have Permission to list that warps.");
+ return;
+ }
+
+ Warps warps = Essentials.getWarps();
+ if (warps.isEmpty()) {
+ throw new Exception("No warps defined");
+ }
+ StringBuilder sb = new StringBuilder();
+ int i = 0;
+ for (String warpName : warps.getWarpNames())
+ {
+ if (perWarpPermission)
+ {
+ if (user.isAuthorized("essentials.warp." + warpName))
+ {
+ if (i++ > 0) sb.append(", ");
+ sb.append(warpName);
+ }
+ }
+ else
+ {
+ if (i++ > 0) sb.append(", ");
+ sb.append(warpName);
+ }
+
+ }
+ user.sendMessage(sb.toString());
+ return;
+ }
+
+ try {
+ if (perWarpPermission)
+ {
+ if (user.isAuthorized("essentials.warp." + args[0]))
+ {
+ user.canAfford(this);
+ user.teleportCooldown();
+ user.warpTo(args[0], this.getName());
+ return;
+ }
+ user.sendMessage("§cYou do not have Permission to use that warp.");
+ return;
+ }
+ user.canAfford(this);
+ user.teleportCooldown();
+ user.warpTo(args[0], this.getName());
+ } catch (Exception ex) {
+ user.sendMessage(ex.getMessage());
+ }
+ }
+}