summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
}