if (writerClassName != null) {
if (writerClassName != null && writer != null) {
    public void readPlugins(String base) throws Exception {        String baseURL = base;        if (base == null) {            baseURL = TiledConfiguration.getInstance().getValue(                    "tiled.plugins.dir");        }        File dir = new File(baseURL);        if (!dir.exists() || !dir.canRead()) {            throw new Exception(                    "Could not open directory for reading plugins: " +                    baseURL);        }        File[] files = dir.listFiles();        for (int i = 0; i < files.length; i++) {            String aPath = files[i].getAbsolutePath();            if (aPath.endsWith(".jar")) {                try {                    JarFile jf = new JarFile(files[i]);                    String readerClassName =                        jf.getManifest().getMainAttributes().getValue(                                "Reader-Class");                    String writerClassName =                        jf.getManifest().getMainAttributes().getValue(                                "Writer-Class");                    Class readerClass = null, writerClass = null;                    // Verify that the jar has the necessary files to be a                    // plugin                    if (readerClassName == null && writerClassName == null) {                        continue;                    }                    JarEntry reader = jf.getJarEntry(                            readerClassName.replace('.', '/') + ".class");                    JarEntry writer = jf.getJarEntry(                            writerClassName.replace('.', '/') + ".class");                    if (readerClassName != null) {                        readerClass = loadFromJar(jf, reader, readerClassName);                    }                    if (writerClassName != null) {                        writerClass = loadFromJar(jf, writer, writerClassName);                    }                    boolean bPlugin = false;                    if (doesImplement(readerClass, "tiled.io.MapReader")) {                        bPlugin = true;                    }                    if (doesImplement(writerClass, "tiled.io.MapWriter")) {                        bPlugin = true;                    }                    if (bPlugin) {                        //System.out.println(                        //        "Added " + files[i].getCanonicalPath());                        super.addURL(new URL("file://" + aPath));                        _add(readerClass);                        _add(writerClass);                    }                } catch (IOException e) {                    e.printStackTrace();                }            }        }    }