summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokamosy <okamosy@gmail.com>2011-08-11 15:52:34 +0100
committerokamosy <okamosy@gmail.com>2011-08-11 15:52:34 +0100
commit65df249510a779a546c8958d3e4445e271502a2f (patch)
tree640430fa0816476d4a503a1e30b50d8f00442f13
parent6fa2b14d65bdeb8aa799a46025747941548bc9e7 (diff)
downloadEssentials-65df249510a779a546c8958d3e4445e271502a2f.tar
Essentials-65df249510a779a546c8958d3e4445e271502a2f.tar.gz
Essentials-65df249510a779a546c8958d3e4445e271502a2f.tar.lz
Essentials-65df249510a779a546c8958d3e4445e271502a2f.tar.xz
Essentials-65df249510a779a546c8958d3e4445e271502a2f.zip
Added support for teleporting to hidden players
Permission: essentials.teleport.hidden
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpo.java23
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java24
2 files changed, 39 insertions, 8 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
index 2a9e34da8..18d818ea1 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
+import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -21,9 +22,23 @@ public class Commandtpo extends EssentialsCommand
}
//Just basically the old tp command
- User p = getPlayer(server, args, 0);
- charge(user);
- user.getTeleport().now(p, false);
- user.sendMessage(Util.i18n("teleporting"));
+ User p = getPlayer(server, args, 0, true);
+ // Check if user is offline
+ if (p.getBase() instanceof OfflinePlayer)
+ {
+ throw new NoSuchFieldException(Util.i18n("playerNotFound"));
+ }
+
+ // Verify permission
+ if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
+ {
+ charge(user);
+ user.getTeleport().now(p, false);
+ user.sendMessage(Util.i18n("teleporting"));
+ }
+ else
+ {
+ throw new NoSuchFieldException(Util.i18n("playerNotFound"));
+ }
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
index 593d17b59..186476a50 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
+import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -21,9 +22,24 @@ public class Commandtpohere extends EssentialsCommand
}
//Just basically the old tphere command
- User p = getPlayer(server, args, 0);
- charge(user);
- p.getTeleport().now(user, false);
- user.sendMessage(Util.i18n("teleporting"));
+ User p = getPlayer(server, args, 0, true);
+
+ // Check if user is offline
+ if (p.getBase() instanceof OfflinePlayer)
+ {
+ throw new NoSuchFieldException(Util.i18n("playerNotFound"));
+ }
+
+ // Verify permission
+ if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
+ {
+ charge(user);
+ p.getTeleport().now(user, false);
+ user.sendMessage(Util.i18n("teleporting"));
+ }
+ else
+ {
+ throw new NoSuchFieldException(Util.i18n("playerNotFound"));
+ }
}
}