예제 #1
0
 private void addClassPath(final URL url) throws IOException {
   final URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
   final Class<URLClassLoader> sysclass = URLClassLoader.class;
   try {
     final Method method = sysclass.getDeclaredMethod("addURL", new Class[] {URL.class});
     method.setAccessible(true);
     method.invoke(sysloader, new Object[] {url});
   } catch (final Throwable t) {
     t.printStackTrace();
     throw new IOException("Error adding " + url + " to system classloader");
   }
 }
예제 #2
0
 public boolean isMineshafterPresent() {
   try {
     Class.forName("mineshafter.MineServer");
     return true;
   } catch (Exception e) {
     return false;
   }
 }
예제 #3
0
  @SuppressWarnings("rawtypes")
  public Class getMinecraftServerClass(String classname) {
    try {
      if (this.minecraft == null) {
        this.minecraft = this.getMinecraftPackage();
      }

      return Class.forName(this.minecraft.getName() + "." + classname);
    } catch (Exception ex) {
      this.getServer()
          .getConsoleSender()
          .sendMessage(
              ChatWriter.pluginMessage(
                  ChatColor.RED
                      + Main._l(
                          "errors.classnotfound",
                          ImmutableMap.of("package", "minecraft server", "class", classname))));
      return null;
    }
  }
예제 #4
0
  public Class<?> getVersionRelatedClass(String className) {
    try {
      Class<?> clazz =
          Class.forName(
              "io.github.yannici.bedwars.Com." + this.getCurrentVersion() + "." + className);
      return clazz;
    } catch (Exception ex) {
      this.getServer()
          .getConsoleSender()
          .sendMessage(
              ChatWriter.pluginMessage(
                  ChatColor.RED
                      + "Couldn't find version related class io.github.yannici.bedwars.Com."
                      + this.getCurrentVersion()
                      + "."
                      + className));
    }

    return null;
  }