From 445ae829c81544ede7b8ca9bf89986e7888d449f Mon Sep 17 00:00:00 2001 From: Brianna O'Keefe Date: Sat, 9 Mar 2019 12:40:22 -0500 Subject: [PATCH] Fix for teleporting to another world before spying. --- .../command/commands/CommandSpy.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/songoda/ultimatemoderation/command/commands/CommandSpy.java b/src/main/java/com/songoda/ultimatemoderation/command/commands/CommandSpy.java index b56e1d9..f56fa08 100644 --- a/src/main/java/com/songoda/ultimatemoderation/command/commands/CommandSpy.java +++ b/src/main/java/com/songoda/ultimatemoderation/command/commands/CommandSpy.java @@ -18,17 +18,27 @@ public class CommandSpy extends AbstractCommand { super(true, true, "Spy"); } - public static void spy(OfflinePlayer player, Player senderP) { + public static void spy(OfflinePlayer oPlayer, Player senderP) { UltimateModeration instance = UltimateModeration.getInstance(); + + Player player = oPlayer.getPlayer(); + + if (player == null) { + senderP.sendMessage(instance.getReferences().getPrefix() + "That player does not exist or is not online."); + return; + } + if (player == senderP) { senderP.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.spy.cant")); return; } + boolean didVanish = false; if (!CommandVanish.isVanished(senderP)) { didVanish = true; CommandVanish.vanish(senderP); } + senderP.teleport(player.getPlayer().getLocation()); spying.put(senderP.getUniqueId(), new Spy(senderP.getLocation(), didVanish)); player.getPlayer().addPassenger(senderP); @@ -55,13 +65,6 @@ public class CommandSpy extends AbstractCommand { return ReturnType.SUCCESS; } - Player player = Bukkit.getPlayer(args[0]); - - if (player == null) { - sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist or is not online."); - return ReturnType.FAILURE; - } - spy(player, senderP); return ReturnType.SUCCESS;