From 18b31a7e50dbbce3410b7244eebeaa06c0147321 Mon Sep 17 00:00:00 2001 From: Iaccidentally Date: Sat, 1 Feb 2014 16:49:54 -0500 Subject: [PATCH] [FIX] Print a proper error when using tpaccept with no requester --- .../essentials/commands/Commandtpaccept.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index afff0f4ab..73d408ddd 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java @@ -18,10 +18,17 @@ public class Commandtpaccept extends EssentialsCommand @Override public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { + final User requester; + try + { + requester = ess.getUser(user.getTeleportRequest()); + } + catch (Exception ex) + { + throw new Exception(_("noPendingRequest")); + } - final User requester = ess.getUser(user.getTeleportRequest()); - - if (requester == null || !requester.isOnline()) + if (!requester.isOnline()) { throw new Exception(_("noPendingRequest")); } @@ -73,8 +80,9 @@ public class Commandtpaccept extends EssentialsCommand { user.sendMessage(_("pendingTeleportCancelled")); ess.showError(requester.getSource(), ex, commandLabel); - } + } user.requestTeleport(null, false); throw new NoChargeException(); } + }