double bdistance = Double.MAX_VALUE;
for (AutoRefPlayer apl : match.getPlayers()) if (apl.isOnline())
{
Location ploc = apl.getPlayer().getLocation();
double dist = ploc.distanceSquared(player.getLocation());
if (dist < bdistance) { bdistance = dist; }
}
// if the spectator should be invisible, change visibility and then redo visibility
boolean vis = bdistance <= SPECTATOR_VISIBILITY_RADIUS * SPECTATOR_VISIBILITY_RADIUS;