super.addURL((new File(aPath)).toURL()); _add(readerClass); _add(writerClass);
    public void readPlugins(String base, JFrame parent) throws Exception {        String baseURL = base;        ProgressMonitor monitor;        if (base == null) {            baseURL = TiledConfiguration.getInstance().getValue(                    "tiled.plugins.dir");        }        File dir = new File(baseURL);        if (!dir.exists() || !dir.canRead()) {            //FIXME: removed for webstart            //throw new Exception(            //        "Could not open directory for reading plugins: " +            //        baseURL);            return;        }        int total = 0;        File[] files = dir.listFiles();        for (int i = 0; i < files.length; i++) {            String aPath = files[i].getAbsolutePath();            if (aPath.endsWith(".jar")) {                total++;            }        }        // Start the progress monitor        monitor = new ProgressMonitor(                parent, "Loading plugins", "", 0, total - 1);        monitor.setProgress(0);        monitor.setMillisToPopup(0);        monitor.setMillisToDecideToPopup(0);        for (int i = 0, j = 0; i < files.length; i++) {            String aPath = files[i].getAbsolutePath();            String aName =                aPath.substring(aPath.lastIndexOf(File.separatorChar) + 1);            if (aPath.endsWith(".jar")) {                try {                    monitor.setNote("Reading " + aName + "...");                    JarFile jf = new JarFile(files[i]);                    monitor.setProgress(i);                    if (jf.getManifest() == null)                        continue;                    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 && reader != null) {                        readerClass = loadFromJar(jf, reader, readerClassName);                    }                    if (writerClassName != null && writer != 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) {                        monitor.setNote("Loading " + aName + "...");                        //System.out.println(                        //        "Added " + files[i].getCanonicalPath());                        super.addURL((new File(aPath)).toURL());                        _add(readerClass);                        _add(writerClass);                    }                } catch (IOException e) {                    e.printStackTrace();                }            }        }    }