From a098055fc9973393538aedb7fd773de8d6e6706e Mon Sep 17 00:00:00 2001 From: triagonal <10545540+triagonal@users.noreply.github.com> Date: Thu, 8 Jul 2021 23:24:40 +1000 Subject: [PATCH] Fix NPE when teleporting offline players (#4332) --- .../java/com/earth2me/essentials/commands/Commandtp.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandtp.java index 54b50007a..bb1a38ece 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandtp.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandtp.java @@ -25,7 +25,6 @@ public class Commandtp extends EssentialsCommand { switch (args.length) { case 0: throw new NotEnoughArgumentsException(); - case 1: final User player = getPlayer(server, user, args, 0, false, true); @@ -33,8 +32,11 @@ public class Commandtp extends EssentialsCommand { throw new Exception(tl("teleportDisabled", player.getDisplayName())); } - if (!player.getBase().isOnline() && user.isAuthorized("essentials.tpoffline")) { - throw new Exception(tl("teleportOffline", player.getDisplayName())); + if (!player.getBase().isOnline()) { + if (user.isAuthorized("essentials.tpoffline")) { + throw new Exception(tl("teleportOffline", player.getDisplayName())); + } + throw new PlayerNotFoundException(); } if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + player.getWorld().getName())) {