diff --git a/common/src/main/java/net/william278/huskhomes/command/TpCommand.java b/common/src/main/java/net/william278/huskhomes/command/TpCommand.java index 01d6a4f5..cc8a5ef9 100644 --- a/common/src/main/java/net/william278/huskhomes/command/TpCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/TpCommand.java @@ -39,7 +39,14 @@ public class TpCommand extends CommandBase implements TabCompletable, ConsoleExe // Find the online user to teleport plugin.getCache().updatePlayerListCache(plugin, onlineUser).thenRun(() -> { - final String playerToTeleport = plugin.getCache().players.stream() + // Get the list of potential teleports, filtered against vanished players, but ensuring the executor is in the list + final List players = plugin.getCache().players; + if (!players.contains(onlineUser.username)) { + players.add(onlineUser.username); + } + + // Find the player to teleport + final String playerToTeleport = players.stream() .filter(user -> user.equalsIgnoreCase(targetPlayerToTeleport)).findFirst() .or(() -> Optional.ofNullable(targetPlayerToTeleport.equals("@s") ? onlineUser.username : null)) .or(() -> plugin.getCache().players.stream().filter(user -> user.toLowerCase().startsWith(targetPlayerToTeleport)).findFirst())