Skip to content

Commit

Permalink
rework /seen to be a little stricter on argument matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
khobbits committed Aug 18, 2014
1 parent 5125a13 commit ffea359
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
51 changes: 29 additions & 22 deletions Essentials/src/com/earth2me/essentials/commands/Commandseen.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,45 @@ protected void seen(final Server server, final CommandSource sender, final Strin
{
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ public static String getFinalArg(final String[] args, final int start)
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)
Expand Down

0 comments on commit ffea359

Please sign in to comment.