Don't show hidden players in /balance unless exact name entered (#3218)

Fixes #2305

Not looking for hidden players within the command, yet looking for offline players.
Only matching a hidden player if the name match was exact (i.e not matching nicknames).
This commit is contained in:
mart-r 2020-05-04 09:36:01 +00:00 committed by GitHub
parent 283c088b21
commit b19dec120a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -23,7 +23,7 @@ public class Commandbalance extends EssentialsCommand {
throw new NotEnoughArgumentsException();
}
User target = getPlayer(server, args, 0, true, true);
User target = getPlayer(server, args, 0, false, true);
sender.sendMessage(tl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess)));
}

View file

@ -124,6 +124,10 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
if (getHidden || canInteractWith(sourceUser, user)) {
return user;
} else { // not looking for hidden and cannot interact (i.e is hidden)
if (getOffline && user.getName().equalsIgnoreCase(searchTerm)) { // if looking for offline and got an exact match
return user;
}
}
throw new PlayerNotFoundException();
}