Skip to content

Commit

Permalink
Fix incorrectly inverted canSee check breaking getNearbyPlayers
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 23, 2024
1 parent 4090a62 commit 45fff0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions main/src/main/java/net/citizensnpcs/util/NMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,9 @@ private static Collection<Player> getNearbyPlayers(Entity from) {
private static Collection<Player> getNearbyPlayers(Entity from, Location location, double radius) {
List<Player> players = Lists.newArrayList();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) {
if (location.getWorld() != player.getWorld() || from != null && Util.canSee(player, from)
|| location.distance(player.getLocation()) > radius)
if (location.getWorld() != player.getWorld() || location.distance(player.getLocation()) > radius)
continue;
if (from != null && !Util.canSee(player, from))
continue;

players.add(player);
Expand Down
4 changes: 2 additions & 2 deletions main/src/main/java/net/citizensnpcs/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public static Vector callPushEvent(NPC npc, double x, double y, double z) {
}

public static boolean canSee(Player player, Entity from) {
if (from instanceof Player) {
if (from instanceof Player)
return player.canSee((Player) from);
}

if (SUPPORTS_ENTITY_CANSEE) {
try {
return player.canSee(from);
Expand Down

0 comments on commit 45fff0f

Please sign in to comment.