Program: 1917
Project: 1917
Buggy source:
@Override public void onEntityTarget(EntityTargetEvent event){
  if (CreatureTask.getCreature(event.getEntity()) != null) {
    HumanNPC creature=CreatureTask.getCreature(event.getEntity()).npc;
    if (creature.isEvil()) {
      creature.getEvil().onRightClick((Player)event.getTarget(),creature);
    }
  }
  if (NPCManager.isNPC(event.getTarget())) {
    event.setCancelled(true);
  }
  if (!(event instanceof NPCEntityTargetEvent)) {
    return;
  }
  NPCEntityTargetEvent e=(NPCEntityTargetEvent)event;
  HumanNPC npc=NPCManager.get(e.getEntity());
  if (npc != null && event.getTarget() instanceof Player) {
    if (e.getNpcReason() == NpcTargetReason.NPC_RIGHTCLICKED) {
      Player player=(Player)event.getTarget();
      if (plugin.validateTool("String_Node_Str",player.getItemInHand().getTypeId(),player.isSneaking()) == true) {
        if (!NPCManager.validateSelected(player,npc.getUID())) {
          NPCManager.selectedNPCs.put(player.getName(),npc.getUID());
          player.sendMessage(ChatColor.GREEN + "String_Node_Str" + StringUtils.wrap(npc.getStrippedName())+ "String_Node_Str"+ StringUtils.wrap("String_Node_Str" + npc.getUID())+ "String_Node_Str");
          return;
        }
      }
      if (plugin.validateTool("String_Node_Str",player.getItemInHand().getTypeId(),player.isSneaking()) == true) {
        CitizensBasicNPCEvent ev=new CitizensBasicNPCEvent(npc,(Player)e.getTarget(),MessageUtils.getText(npc,(Player)e.getTarget()));
        plugin.getServer().getPluginManager().callEvent(ev);
      }
      if (npc.isTrader()) {
        npc.getTrader().onRightClick(player,npc);
      }
      if (npc.isWizard()) {
        npc.getWizard().onRightClick(player,npc);
      }
      if (npc.isBlacksmith()) {
        npc.getBlacksmith().onRightClick(player,npc);
      }
      if (npc.isBandit()) {
        npc.getBandit().onRightClick(player,npc);
      }
      if (npc.isQuester()) {
        npc.getQuester().onRightClick(player,npc);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onEntityTarget(EntityTargetEvent event){
  if (!(event instanceof NPCEntityTargetEvent)) {
    return;
  }
  NPCEntityTargetEvent e=(NPCEntityTargetEvent)event;
  if (CreatureTask.getCreature(event.getEntity()) != null) {
    HumanNPC creature=CreatureTask.getCreature(event.getEntity()).npc;
    if (creature.isEvil()) {
      if (e.getNpcReason() == NpcTargetReason.NPC_RIGHTCLICKED) {
        creature.getEvil().onRightClick((Player)event.getTarget(),creature);
      }
    }
  }
  if (NPCManager.isNPC(event.getTarget())) {
    event.setCancelled(true);
  }
  HumanNPC npc=NPCManager.get(e.getEntity());
  if (npc != null && event.getTarget() instanceof Player) {
    if (e.getNpcReason() == NpcTargetReason.NPC_RIGHTCLICKED) {
      Player player=(Player)event.getTarget();
      if (plugin.validateTool("String_Node_Str",player.getItemInHand().getTypeId(),player.isSneaking()) == true) {
        if (!NPCManager.validateSelected(player,npc.getUID())) {
          NPCManager.selectedNPCs.put(player.getName(),npc.getUID());
          player.sendMessage(ChatColor.GREEN + "String_Node_Str" + StringUtils.wrap(npc.getStrippedName())+ "String_Node_Str"+ StringUtils.wrap("String_Node_Str" + npc.getUID())+ "String_Node_Str");
          return;
        }
      }
      if (plugin.validateTool("String_Node_Str",player.getItemInHand().getTypeId(),player.isSneaking()) == true) {
        CitizensBasicNPCEvent ev=new CitizensBasicNPCEvent(npc,(Player)e.getTarget(),MessageUtils.getText(npc,(Player)e.getTarget()));
        plugin.getServer().getPluginManager().callEvent(ev);
      }
      if (npc.isTrader()) {
        npc.getTrader().onRightClick(player,npc);
      }
      if (npc.isWizard()) {
        npc.getWizard().onRightClick(player,npc);
      }
      if (npc.isBlacksmith()) {
        npc.getBlacksmith().onRightClick(player,npc);
      }
      if (npc.isBandit()) {
        npc.getBandit().onRightClick(player,npc);
      }
      if (npc.isQuester()) {
        npc.getQuester().onRightClick(player,npc);
      }
    }
  }
}