summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-11-15 22:47:02 +0100
committersnowleo <schneeleo@gmail.com>2011-11-15 22:51:14 +0100
commit77dfa1ba1821c95a7e78850029a6638d7f22246b (patch)
tree98996c1f17958821b47510795e85c2521dcf4a1d
parent0eaae89739d1a6dc6159e6feee22d2e764869f2f (diff)
downloadEssentials-77dfa1ba1821c95a7e78850029a6638d7f22246b.tar
Essentials-77dfa1ba1821c95a7e78850029a6638d7f22246b.tar.gz
Essentials-77dfa1ba1821c95a7e78850029a6638d7f22246b.tar.lz
Essentials-77dfa1ba1821c95a7e78850029a6638d7f22246b.tar.xz
Essentials-77dfa1ba1821c95a7e78850029a6638d7f22246b.zip
Prevent that players are teleported to offline players using /tpa and players that lost their tpahere permission
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java21
1 files changed, 12 insertions, 9 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
index 043f23172..fd9eeaa84 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
+import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.Trade;
import org.bukkit.Server;
import com.earth2me.essentials.User;
@@ -14,34 +15,36 @@ public class Commandtpaccept extends EssentialsCommand
}
@Override
- public void run(Server server, User user, String commandLabel, String[] args) throws Exception
+ public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
- User p = user.getTeleportRequest();
- if (p == null)
+ final User target = user.getTeleportRequest();
+ if (target == null
+ || target.getBase() instanceof OfflinePlayer
+ || (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere")))
{
throw new Exception(Util.i18n("noPendingRequest"));
}
- Trade charge = new Trade(this.getName(), ess);
+ final Trade charge = new Trade(this.getName(), ess);
if (user.isTeleportRequestHere())
{
charge.isAffordableFor(user);
}
else
{
- charge.isAffordableFor(p);
+ charge.isAffordableFor(target);
}
user.sendMessage(Util.i18n("requestAccepted"));
- p.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
-
+ target.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
+
if (user.isTeleportRequestHere())
{
- user.getTeleport().teleport(p, charge);
+ user.getTeleport().teleport(target, charge);
}
else
{
- p.getTeleport().teleport(user, charge);
+ target.getTeleport().teleport(user, charge);
}
user.requestTeleport(null, false);
}