reportPluginMessages(errors);
    public void saveMap(String filename, boolean bSaveAs) {        if (bSaveAs || filename == null) {            JFileChooser ch;            if (filename == null) {                ch = new JFileChooser();            } else {                ch = new JFileChooser(filename);            }            try {                MapWriter writers[] = (MapWriter[]) pluginLoader.getWriters();                for(int i = 0; i < writers.length; i++) {                    ch.addChoosableFileFilter(new TiledFileFilter(                                writers[i].getFilter(), writers[i].getName()));                }            } catch (Throwable e) {                JOptionPane.showMessageDialog(appFrame,                        "Error while loading plugins: " + e.getMessage(),                        "Error while saving map",                        JOptionPane.ERROR_MESSAGE);                e.printStackTrace();            }            ch.addChoosableFileFilter(                    new TiledFileFilter(TiledFileFilter.FILTER_TMX));                        if (ch.showSaveDialog(appFrame) == JFileChooser.APPROVE_OPTION) {                filename = ch.getSelectedFile().getAbsolutePath();                configuration.addConfigPair("tmx.save.maplocation",                        filename.substring(0, filename.lastIndexOf(                                File.separatorChar) + 1));            } else {                // User cancelled operation, do nothing                return;            }        }        try {            MapWriter mw = null;            if (filename.endsWith("tmx")) {                // Override, so people can't overtake our format                mw = new XMLMapWriter();            } else {                mw = (MapWriter)pluginLoader.getWriterFor(                        filename.substring(filename.lastIndexOf('.') + 1));            }            if (mw != null) {                mw.writeMap(currentMap, filename);                currentMap.setFilename(filename);                updateRecent(filename);                undoStack.commitSave();                updateTitle();            } else {                JOptionPane.showMessageDialog(appFrame,                        "Unsupported map format", "Error while saving map",                        JOptionPane.ERROR_MESSAGE);            }        } catch (Exception e) {            e.printStackTrace();            JOptionPane.showMessageDialog(appFrame,                    "Error while saving " + filename + ": " + e.toString(),                    "Error while saving map",                    JOptionPane.ERROR_MESSAGE);        }        configuration.remove("tmx.save.maplocation");    }