Skip to content

Commit

Permalink
fix: potential canSee NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
bridge committed Apr 26, 2024
1 parent c16e9d6 commit b4cc8ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public void enable() {

@Override
public boolean canSee(@NotNull final ChatUser user, @NotNull final ChatUser target) {
return user.playerNotNull().canSee(target.playerNotNull());
return user.player()
.map(player -> target.player().map(player::canSee).orElse(true))
.orElse(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public void enable() {

@Override
public boolean canSee(@NotNull final ChatUser user, @NotNull final ChatUser target) {
return VanishAPI.canSee(user.playerNotNull(), target.playerNotNull());
return user.player()
.map(player -> target.player().map(targetPlayer -> VanishAPI.canSee(player, targetPlayer))
.orElse(true))
.orElse(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public void enable() {

@Override
public boolean canSee(@NotNull final ChatUser user, @NotNull final ChatUser target) {
return user.playerNotNull().canSee(target.playerNotNull());
return user.player()
.map(player -> target.player().map(player::canSee).orElse(true))
.orElse(true);
}
}

0 comments on commit b4cc8ed

Please sign in to comment.