package me.km;

import java.io.File;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

public class ClassLoaderUtils {
    public static void loadDependencies() {
        URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();

        try {
            Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
            method.setAccessible(true);
            method.invoke(sysloader, getURL("mods/libs/SnuviScriptRecoded.jar"));
            method.invoke(sysloader, getURL("mods/libs/mysql-connector-java.jar"));
        } catch(Throwable t) {
            t.printStackTrace();
        }
    }

    private static URL getURL(String s) throws MalformedURLException {
        return new File(s).toURI().toURL();
    }
}
