/**
   * Matches an item and gets the appropriate item stack.
   *
   * @param source
   * @param name
   * @return iterator for players
   * @throws CommandException
   */
  public ItemStack matchItem(CommandSender source, String name) throws CommandException {

    int id = 0;
    int dmg = 0;
    String dataName = null;

    if (name.contains(":")) {
      String[] parts = name.split(":");
      dataName = parts[1];
      name = parts[0];
    }

    try {
      id = Integer.parseInt(name);
    } catch (NumberFormatException e) {
      // First check the configurable list of aliases
      Integer idTemp = CommandBook.inst().itemNames.get(name.toLowerCase());

      if (idTemp != null) {
        id = (int) idTemp;
      } else {
        // Then check WorldEdit
        ItemType type = ItemType.lookup(name);

        if (type == null) {
          throw new CommandException("No item type known by '" + name + "'");
        }

        id = type.getID();
      }
    }

    // If the user specified an item data or damage value, let's try
    // to parse it!
    if (dataName != null) {
      dmg = matchItemData(id, dataName);
    }
    return new ItemStack(id, 1, (short) dmg);
  }