summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-05-20 18:50:14 +0100
committerKHobbits <rob@khobbits.co.uk>2013-05-20 18:50:14 +0100
commit5c05870490e85188aa042d96a871b17f8b3145e1 (patch)
tree88270db1a25262b46cea1f48d3e3dc3f161b8a5a
parentd76fe946b7f1f403da99a3ea4da9a02e55a35cda (diff)
downloadEssentials-5c05870490e85188aa042d96a871b17f8b3145e1.tar
Essentials-5c05870490e85188aa042d96a871b17f8b3145e1.tar.gz
Essentials-5c05870490e85188aa042d96a871b17f8b3145e1.tar.lz
Essentials-5c05870490e85188aa042d96a871b17f8b3145e1.tar.xz
Essentials-5c05870490e85188aa042d96a871b17f8b3145e1.zip
Improve user matching
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
index 0573c02d8..6d2f775ed 100644
--- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
+++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
@@ -43,18 +43,24 @@ public abstract class EssentialsCommand implements IEssentialsCommand
return name;
}
+ @Deprecated
protected User getPlayer(final Server server, final String[] args, final int pos) throws NoSuchFieldException, NotEnoughArgumentsException
{
- return getPlayer(server, args, pos, false, false);
+ return getPlayer(server, null, args, pos, false, false);
}
protected User getPlayer(final Server server, final User user, final String[] args, final int pos) throws NoSuchFieldException, NotEnoughArgumentsException
{
- return getPlayer(server, args, pos, user.isAuthorized("essentials.vanish.interact"), false);
+ return getPlayer(server, user, args, pos, user.isAuthorized("essentials.vanish.interact"), false);
}
protected User getPlayer(final Server server, final String[] args, final int pos, boolean getHidden, final boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException
{
+ return getPlayer(server, null, args, pos, getHidden, getOffline);
+ }
+
+ private User getPlayer(final Server server, final User sourceUser, final String[] args, final int pos, boolean getHidden, final boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException
+ {
if (args.length <= pos)
{
throw new NotEnoughArgumentsException();
@@ -70,7 +76,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
{
throw new PlayerNotFoundException();
}
- if (!getHidden && user.isHidden())
+ if (!getHidden && user.isHidden() || user.equals(sourceUser))
{
throw new PlayerNotFoundException();
}
@@ -83,13 +89,13 @@ public abstract class EssentialsCommand implements IEssentialsCommand
for (Player player : matches)
{
final User userMatch = ess.getUser(player);
- if (userMatch.getDisplayName().startsWith(args[pos]) && (getHidden || !userMatch.isHidden()))
+ if (userMatch.getDisplayName().startsWith(args[pos]) && (getHidden || !userMatch.isHidden() || userMatch.equals(sourceUser)))
{
return userMatch;
}
}
final User userMatch = ess.getUser(matches.get(0));
- if (getHidden || !userMatch.isHidden())
+ if (getHidden || !userMatch.isHidden() || userMatch.equals(sourceUser))
{
return userMatch;
}