Example #1
0
  /** DOCUMENT ME! */
  public void loadRaids() {
    File f = new File(REPO);

    if (!f.exists()) {
      return;
    }

    FileInputStream fIn = null;
    ObjectInputStream oIn = null;

    try {
      fIn = new FileInputStream(REPO);
      oIn = new ObjectInputStream(fIn);
      // de-serializing object
      raids = (HashMap<String, GregorianCalendar>) oIn.readObject();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } finally {
      try {
        oIn.close();
        fIn.close();
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    }
  }
Example #2
0
  public static Plugin loadPlugin(String name) {
    try {
      ArrayList<URL> paths = new ArrayList<URL>();
      File f = new File("plugins/" + name + ".jar");
      paths.add(f.toURI().toURL());

      File f2 = new File("plugins/lib");
      for (File ff : f2.listFiles()) {
        paths.add(ff.toURI().toURL());
      }
      URL[] urls = new URL[paths.size()];
      paths.toArray(urls);
      URLClassLoader newLoader = new URLClassLoader(urls);
      Plugin p = (Plugin) newLoader.loadClass(name).newInstance();
      loadedPlugins.put(name, p);
      return p;
    } catch (Exception ex) {
      System.err.println("Failed to load plugin: " + ex.getMessage());
      ex.printStackTrace();
    }
    return null;
  }