Program: 1948
Project: 1948
Buggy source:
@Override public void run(){
  for (  Entry<Integer,HumanNPC> entry : NPCManager.getList().entrySet()) {
    HumanNPC npc=entry.getValue();
    if (npc.isGuard()) {
      GuardNPC guard=npc.getGuard();
      if (guard.isBouncer()) {
        Location loc=npc.getLocation();
        for (        Entity temp : npc.getPlayer().getNearbyEntities(guard.getHalvedRadius(),guard.getProtectionRadius(),guard.getHalvedRadius())) {
          if (!(temp instanceof LivingEntity)) {
            continue;
          }
          entity=(LivingEntity)temp;
          String name="String_Node_Str";
          if (entity instanceof Player) {
            Player player=(Player)entity;
            if (!NPCManager.validateOwnership(player,npc.getUID())) {
              name=player.getName();
            }
          }
 else {
            name=getTypeFromEntity(entity);
          }
          if (LocationUtils.checkLocation(loc,entity.getLocation(),npc.getGuard().getProtectionRadius())) {
            cacheActions(npc,entity,entity.getEntityId(),name);
          }
 else {
            resetActions(entity.getEntityId(),name,npc);
          }
        }
        entity=null;
      }
 else       if (guard.isBodyguard()) {
        String owner=npc.getOwner();
        Player p=Bukkit.getServer().getPlayer(owner);
        if (p != null && p.isOnline()) {
          Location ownerloc=p.getLocation();
          if (NPCManager.get(npc.getUID()) == null) {
            npc.getNPCData().setLocation(p.getLocation());
          }
          for (          Entity temp : p.getNearbyEntities(ownerloc.getX(),ownerloc.getY(),ownerloc.getZ())) {
            if (!(temp instanceof LivingEntity)) {
              continue;
            }
            entity=(LivingEntity)temp;
            String name="String_Node_Str";
            if (entity instanceof Player) {
              Player player=(Player)entity;
              if (!NPCManager.validateOwnership(player,npc.getUID())) {
                name=player.getName();
              }
            }
 else {
              name=getTypeFromEntity(entity);
            }
            if (LocationUtils.checkLocation(ownerloc,entity.getLocation(),25)) {
              cacheActions(npc,entity,entity.getEntityId(),name);
            }
 else {
              resetActions(entity.getEntityId(),name,npc);
            }
          }
          entity=null;
          if (LocationUtils.checkLocation(npc.getLocation(),p.getLocation(),25)) {
            npc.target(p,false,-1,2,25);
          }
 else {
            npc.moveTo(p.getLocation());
          }
        }
 else {
          if (NPCManager.get(npc.getUID()) != null) {
            PathUtils.cancelPath(npc);
            NPCManager.despawn(npc.getUID());
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  for (  Entry<Integer,HumanNPC> entry : NPCManager.getList().entrySet()) {
    HumanNPC npc=entry.getValue();
    if (npc.isGuard()) {
      GuardNPC guard=npc.getGuard();
      if (guard.isBouncer()) {
        Location loc=npc.getLocation();
        for (        Entity temp : npc.getPlayer().getNearbyEntities(guard.getHalvedRadius(),guard.getProtectionRadius(),guard.getHalvedRadius())) {
          if (!(temp instanceof LivingEntity)) {
            continue;
          }
          entity=(LivingEntity)temp;
          String name="String_Node_Str";
          if (entity instanceof Player) {
            Player player=(Player)entity;
            if (!NPCManager.validateOwnership(player,npc.getUID())) {
              name=player.getName();
            }
          }
 else {
            name=getTypeFromEntity(entity);
          }
          if (LocationUtils.checkLocation(loc,entity.getLocation(),npc.getGuard().getProtectionRadius())) {
            cacheActions(npc,entity,entity.getEntityId(),name);
          }
 else {
            resetActions(entity.getEntityId(),name,npc);
          }
        }
        entity=null;
      }
 else       if (guard.isBodyguard()) {
        String owner=npc.getOwner();
        Player p=Bukkit.getServer().getPlayer(owner);
        if (p != null && p.isOnline()) {
          Location ownerloc=p.getLocation();
          if (NPCManager.get(npc.getUID()) == null) {
            npc.getNPCData().setLocation(p.getLocation());
          }
          for (          Entity temp : p.getNearbyEntities(ownerloc.getX(),ownerloc.getY(),ownerloc.getZ())) {
            if (!(temp instanceof LivingEntity)) {
              continue;
            }
            entity=(LivingEntity)temp;
            String name="String_Node_Str";
            if (entity instanceof Player) {
              Player player=(Player)entity;
              if (!NPCManager.validateOwnership(player,npc.getUID())) {
                name=player.getName();
              }
            }
 else {
              name=getTypeFromEntity(entity);
            }
            if (LocationUtils.checkLocation(ownerloc,entity.getLocation(),25)) {
              cacheActions(npc,entity,entity.getEntityId(),name);
            }
 else {
              resetActions(entity.getEntityId(),name,npc);
            }
          }
          entity=null;
          if (LocationUtils.checkLocation(npc.getLocation(),p.getLocation(),25)) {
            npc.target(p,false,-1,2,25);
          }
 else {
            npc.teleport(p.getLocation());
          }
        }
 else {
          if (NPCManager.get(npc.getUID()) != null) {
            PathUtils.cancelPath(npc);
            NPCManager.despawn(npc.getUID());
          }
        }
      }
    }
  }
}