private boolean setModDir() {
        if (!useModDirCheckBox.isSelected()) {
            if (hadModDir)
                config.removeVariable("moddir");
            return true;
        } else {
            StringBuilder filename = new StringBuilder(mainDirTextField.getText());
            char last = filename.charAt(filename.length()-1);
            if (last != '/' && last != '\\')
                filename.append(File.separatorChar);
            
            String mainDir = filename.toString();   // in case the next operation fails
            
            File modDir = new File(filename.append(modDirTextField.getText()).toString());
            
            if (!modDir.exists()) {
                modDir = new File(mainDir + "mod" + File.separatorChar + modDirTextField.getText());
            }
            
            if (!modDir.exists()) {
                int check = JOptionPane.showConfirmDialog(this,
                        "The mod directory does not exist. Do you want to continue?",
                        "Confirmation",
                        JOptionPane.YES_NO_OPTION,
                        JOptionPane.WARNING_MESSAGE);
                if (check == JOptionPane.NO_OPTION)
                    return false;
                else {
                    config.setString("moddir", modDirTextField.getText().replaceAll("[/\\\\]", "/"), true);
                    return true;
                }
            } else {
                config.setString("moddir", modDirTextField.getText().replaceAll("[/\\\\]", "/"), true);
                return true;
            }
        }
    }