diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandseen.java index 709738719..9e2d4abf9 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandseen.java @@ -27,12 +27,14 @@ public class Commandseen extends EssentialsCommand { @Override protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { - final boolean showBan = sender.isAuthorized("essentials.seen.banreason", ess); - final boolean showIp = sender.isAuthorized("essentials.seen.ip", ess); - final boolean showLocation = sender.isAuthorized("essentials.seen.location", ess); if (args.length < 1) { throw new NotEnoughArgumentsException(); } + final boolean showBan = sender.isAuthorized("essentials.seen.banreason", ess); + final boolean showIp = sender.isAuthorized("essentials.seen.ip", ess); + final boolean showLocation = sender.isAuthorized("essentials.seen.location", ess); + final boolean searchAccounts = commandLabel.contains("alts") && sender.isAuthorized("essentials.seen.alts", ess); + User player; // Check by uuid, if it fails check by name. try { @@ -43,15 +45,20 @@ public class Commandseen extends EssentialsCommand { } if (player == null) { - if (sender.isAuthorized("essentials.seen.ipsearch", ess) && FormatUtil.validIP(args[0])) { - seenIP(sender, args[0]); - return; - } else if (ess.getServer().getBanList(BanList.Type.IP).isBanned(args[0])) { - sender.sendMessage(tl("isIpBanned", args[0])); - return; - } else if (BanLookup.isBanned(ess, args[0])) { - sender.sendMessage(tl("whoisBanned", showBan ? BanLookup.getBanEntry(ess, args[0]).getReason() : tl("true"))); - return; + if (!searchAccounts) { + if (sender.isAuthorized("essentials.seen.ipsearch", ess) && FormatUtil.validIP(args[0])) { + if (ess.getServer().getBanList(BanList.Type.IP).isBanned(args[0])) { + sender.sendMessage(tl("isIpBanned", args[0])); + } + seenIP(sender, args[0], args[0]); + return; + } else if (ess.getServer().getBanList(BanList.Type.IP).isBanned(args[0])) { + sender.sendMessage(tl("isIpBanned", args[0])); + return; + } else if (BanLookup.isBanned(ess, args[0])) { + sender.sendMessage(tl("whoisBanned", showBan ? BanLookup.getBanEntry(ess, args[0]).getReason() : tl("true"))); + return; + } } ess.getScheduler().runTaskAsynchronously(ess, new Runnable() { @Override @@ -73,16 +80,18 @@ public class Commandseen extends EssentialsCommand { } private void showUserSeen(final User user) throws Exception { - showSeenMessage(sender, user, showBan, showIp, showLocation); + showSeenMessage(sender, user, searchAccounts, showBan, showIp, showLocation); } }); } else { - showSeenMessage(sender, player, showBan, showIp, showLocation); + showSeenMessage(sender, player, searchAccounts, showBan, showIp, showLocation); } } - private void showSeenMessage(final CommandSource sender, final User player, final boolean showBan, final boolean showIp, final boolean showLocation) { - if (player.getBase().isOnline() && canInteractWith(sender, player)) { + private void showSeenMessage(final CommandSource sender, final User player, final boolean searchAccounts, final boolean showBan, final boolean showIp, final boolean showLocation) { + if (searchAccounts) { + seenIP(sender, player.getLastLoginAddress(), player.getDisplayName()); + } else if (player.getBase().isOnline() && canInteractWith(sender, player)) { seenOnline(sender, player, showIp); } else { seenOffline(sender, player, showBan, showIp, showLocation); @@ -183,14 +192,10 @@ public class Commandseen extends EssentialsCommand { } } - private void seenIP(final CommandSource sender, final String ipAddress) { + private void seenIP(final CommandSource sender, final String ipAddress, final String display) { final UserMap userMap = ess.getUserMap(); - if (ess.getServer().getBanList(BanList.Type.IP).isBanned(ipAddress)) { - sender.sendMessage(tl("isIpBanned", ipAddress)); - } - - sender.sendMessage(tl("runningPlayerMatch", ipAddress)); + sender.sendMessage(tl("runningPlayerMatch", display)); ess.runTaskAsynchronously(() -> { final List matches = new ArrayList<>(); diff --git a/Essentials/src/main/resources/plugin.yml b/Essentials/src/main/resources/plugin.yml index 515b64e50..26e95a656 100644 --- a/Essentials/src/main/resources/plugin.yml +++ b/Essentials/src/main/resources/plugin.yml @@ -391,7 +391,7 @@ commands: seen: description: Shows the last logout time of a player. usage: / - aliases: [eseen] + aliases: [eseen, ealts, alts] sell: description: Sells the item currently in your hand. usage: / <||hand|inventory|blocks> [-][amount]