summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2014-08-18 21:00:03 +0100
committerKHobbits <rob@khobbits.co.uk>2014-08-18 21:00:03 +0100
commit98db85cb34ef292951089562d450e453d96c6316 (patch)
treeae06699f18a46c587616380ba3c4e21f640df236
parent10e0ac2d4803dc4de99d7649d4c3bfa02152f59b (diff)
downloadEssentials-98db85cb34ef292951089562d450e453d96c6316.tar
Essentials-98db85cb34ef292951089562d450e453d96c6316.tar.gz
Essentials-98db85cb34ef292951089562d450e453d96c6316.tar.lz
Essentials-98db85cb34ef292951089562d450e453d96c6316.tar.xz
Essentials-98db85cb34ef292951089562d450e453d96c6316.zip
rework /seen to be a little stricter on argument matching.
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandseen.java51
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java15
2 files changed, 44 insertions, 22 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
index 35c719cf4..fd4ad69b1 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
@@ -43,38 +43,45 @@ public class Commandseen extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
- try
+ User player = ess.getOfflineUser(args[0]);
+ if (player == null)
{
- User user = getPlayer(server, sender, args, 0);
- seenOnline(server, sender, user, showBan, extra);
- }
- catch (NoSuchFieldException e)
- {
- User player = ess.getOfflineUser(args[0]);
- if (player == null)
+ if (ipLookup && FormatUtil.validIP(args[0]))
{
- if (ipLookup && FormatUtil.validIP(args[0]))
- {
- seenIP(server, 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]))
+ seenIP(server, 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;
+ }
+ else
+ {
+ try
{
- sender.sendMessage(tl("whoisBanned", showBan ? BanLookup.getBanEntry(ess, args[0]).getReason() : tl("true")));
- return;
+ player = getPlayer(server, sender, args, 0);
}
- else
+ catch (NoSuchFieldException e)
{
throw new PlayerNotFoundException();
}
}
+ }
+ if (player.getBase().isOnline() && canInteractWith(sender, player))
+ {
+ seenOnline(server, sender, player, showBan, extra);
+ }
+ else
+ {
seenOffline(server, sender, player, showBan, extra);
}
+
}
private void seenOnline(final Server server, final CommandSource sender, final User user, final boolean showBan, final boolean extra) throws Exception
diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
index ee605ffb3..bfd1843be 100644
--- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
+++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
@@ -211,6 +211,21 @@ public abstract class EssentialsCommand implements IEssentialsCommand
return bldr.toString();
}
+ boolean canInteractWith(CommandSource interactor, User interactee)
+ {
+ if (interactor == null)
+ {
+ return !interactee.isHidden();
+ }
+
+ if (interactor.isPlayer())
+ {
+ return canInteractWith(ess.getUser(interactor.getPlayer()), interactee);
+ }
+
+ return true; // console
+ }
+
private static boolean canInteractWith(User interactor, User interactee)
{
if (interactor == null)