package com.polarbirds.screencapture.plugin;

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;

public class PluginHandler {
    private List<PluginInterface> loadedPlugins;

    public PluginHandler(List<String[]> in) {
        loadedPlugins = new ArrayList<PluginInterface>();

        System.out.println("Loading plugins:");

        for(String[] plugin : in){
            String path = plugin[0];
            String className = plugin[1];
            try {
                ClassLoader cl;
                if (path.startsWith("internal")){
                    cl = getClass().getClassLoader();
                } else {
                    cl = new URLClassLoader(new URL[]{new URL(path)});
                }

                PluginInterface newPlugin = (PluginInterface) cl.loadClass(className).newInstance();
                loadedPlugins.add(newPlugin);

                System.out.println(newPlugin.manifest()); //Debug
            } catch (ClassCastException | InstantiationException | IllegalAccessException ex){
                System.err.println("Failed to load \""+plugin+"\" as a plugin.");
                ex.printStackTrace();
            } catch (ClassNotFoundException | MalformedURLException ex){
                System.err.println("Could not find plugin \""+plugin+"\".");
                ex.printStackTrace();
            } catch (Exception ex){
                /* Plugins may fail to initialize properly, which would
                 * leave them in an invalid state. We should therefore let them throw exceptions
                 * which will make it possible for us to ignore the plugin that failed.
                 */
                System.err.println("Other exception occured while loading \""+plugin+"\"" );
                ex.printStackTrace();
            }

        }

        System.out.println("Loaded "+loadedPlugins.size()+" plugin"+(loadedPlugins.size()>1?"s":"")+".");
    }

    public List<PluginInterface> getLoadedPlugins(){
        return loadedPlugins;
    }
}

@@ -1165,24 +1165,27 @@
 d %5C%22%22+plugin
+%5B1%5D
 +%22%5C%22 as a pl
@@ -1376,13 +1376,35 @@
 ugin
+%5B1%5D
 +%22%5C%22.
+ Please verify url.
 %22);%0A
@@ -1794,13 +1794,15 @@
 ln(%22
-Other
+Unknown
  exc
@@ -1840,16 +1840,19 @@
 %22+plugin
+%5B1%5D
 +%22%5C%22%22 );
@@ -2009,16 +2009,17 @@
 ze()
-%3E
+==
 1?%22
-s
 %22:%22
+s
 %22)+%22

Update PluginHandler.java