fix NPE in IPlayerManager#getOnlyVisibleFor(...)

This commit is contained in:
Marc Baloup 2022-06-22 01:37:04 +02:00
parent db27f9e15f
commit b2c2d98dd1
Signed by: marcbal
GPG Key ID: BBC0FE3ABC30B893
1 changed files with 3 additions and 2 deletions

View File

@ -115,12 +115,13 @@ public abstract class IPlayerManager<OP extends IOnlinePlayer, OF extends IOffPl
public List<OP> getOnlyVisibleFor(OF viewer) {
List<OP> players = getAll();
players.removeIf(op -> op.isVanishedFor(viewer));
if (viewer != null)
players.removeIf(op -> op.isVanishedFor(viewer));
return players;
}
public List<OP> getOnlyVisibleFor(OP viewer, boolean sameServerOnly) {
if (sameServerOnly && viewer.getServerName() == null)
if (sameServerOnly && (viewer == null || viewer.getServerName() == null))
return Collections.emptyList();
@SuppressWarnings("unchecked")