/**
   * see CommandHelper.marketAdd() for now
   *
   * @param sender
   * @param args
   * @return
   */
  private boolean marketAdd(CommandSender sender, String[] args) {

    String addendNumber = null,
        addendData = null,
        addendName = null,
        addendValue = null,
        addendMinValue = null,
        addendMaxValue = null,
        addendChangeRate = null,
        addendSpread = null;
    try {

      addendNumber = args[1];
      addendData = args[2];
      addendName = args[3];
      addendValue = args[4];
      addendMinValue = args[5];
      addendMaxValue = args[6];
      addendChangeRate = args[7];
      addendSpread = args[8];

    } catch (ArrayIndexOutOfBoundsException e) {

      new CommandHelper("Too few arguments", sender).marketAddHelp();
      return false;
    }

    Commodities commodity = new Commodities();

    try {

      commodity.setNumber(Integer.valueOf(addendNumber));
      commodity.setData(Integer.valueOf(addendData));
      commodity.setName(addendName);
      commodity.setValue(Double.valueOf(addendValue));
      commodity.setMaxValue(Double.valueOf(addendMaxValue));
      commodity.setMinValue(Double.valueOf(addendMinValue));
      commodity.setChangeRate(Double.valueOf(addendChangeRate));
      commodity.setSpread(Double.valueOf(addendSpread));

    } catch (NumberFormatException e) {

      new CommandHelper("Invalid Arguments", sender).marketAddHelp();
      return false;
    }
    System.out.println(commodity.toString());
    try {

      new CommodityDBAdder(this).addCommodity(commodity);

    } catch (DuplicateCommodityException e) {

      sender.sendMessage(e.getMessage());
      return false;
    }

    sender.sendMessage(commodity.getName() + " successfully added to the database");

    return true;
  }
  /** use this in the case that we need to update from the old way of storing data in config.yml */
  @SuppressWarnings("deprecation")
  private void switchToDatabase() {

    logger.info("[" + pdfFile.getName() + "] Converting flatfile to database...");

    // load old config file
    org.bukkit.configuration.Configuration items = plugin.getConfig();

    // populate the database with existing values
    logger.info("[" + plugin.getDescription().getName() + "] Populating database ...");
    for (String item : items.getKeys(false)) {

      Commodities commodity =
          plugin
              .getDatabase()
              .find(Commodities.class)
              .where()
              .ieq("name", item)
              .ieq("number", items.getString(item + ".number"))
              .findUnique();

      if (commodity == null) {

        commodity = new Commodities();
        commodity.setName(item);

        for (String key : items.getConfigurationSection(item).getKeys(false)) {

          String value = items.getString(item + "." + key);

          if (key.equalsIgnoreCase("value")) commodity.setValue(Double.valueOf(value));
          if (key.equalsIgnoreCase("number")) commodity.setNumber(Integer.valueOf(value));
          if (key.equalsIgnoreCase("minValue")) commodity.setMinValue(Double.valueOf(value));
          if (key.equalsIgnoreCase("maxValue")) commodity.setMaxValue(Double.valueOf(value));
          if (key.equalsIgnoreCase("changeRate")) commodity.setChangeRate(Double.valueOf(value));
          if (key.equalsIgnoreCase("data")) commodity.setData(Integer.valueOf(value));
          if (key.equalsIgnoreCase("spread")) commodity.setSpread(Double.valueOf(value));
        }
      } else {
        logger.warning(
            "["
                + pdfFile.getName()
                + "] Duplicate commodity found, that can't be good. You may want to restore the config.yml backup, delete Dynamark.db (or equivilant), then check the file for commodities with the same \"number\", correct the issue, and then restart your server to try again.");
        continue;
      }

      plugin.getDatabase().save(commodity);
      commodity = null;
    }

    // mv config.yml to config.yml.bak
    logger.info("[" + plugin.getDescription().getName() + "] backing up config.yml...");

    File configFlatFile = new File(directory + File.separator + "config.yml");
    File backupName = new File(directory + File.separator + "config.yml.bak");

    configFlatFile.renameTo(backupName);

    //  rm config.yml.example
    File toDelete = new File(directory + File.separator + "config.yml.EXAMPLE");

    toDelete.delete();

    logger.info(
        "[" + plugin.getDescription().getName() + "] Successfully converted flatfile to database");
  }