예제 #1
0
 @Override
 public void reload() {
   MinecraftScriptMod.getLogger().fine("Reloading Scripting Scope");
   loadScope(false);
   loadAllScripts(_scriptsDirectory, false);
   loadAllScripts(new File(DimensionManager.getCurrentSaveRootDirectory(), "scripts"), true);
 }
예제 #2
0
  @Override
  public void loadAllScripts(File scriptsDir, boolean aux) {
    if (!aux) {
      _scriptsDirectory = scriptsDir;
    }

    if (scriptsDir == null) {
      return;
    }

    if (!scriptsDir.exists()) {
      scriptsDir.mkdirs();
    }

    enterContext();

    for (File f : scriptsDir.listFiles()) {
      try {
        if (!f.getName()
            .startsWith(
                "init_")) { // this should make including libarys easier and should pave the way for
          // a require compatable system
          continue;
        }
        MinecraftScriptMod.getLogger().info("Loading " + f.toString());
        FileReader fr = new FileReader(f);
        mcJavascriptContext.evaluateReader(mcJavascriptScope, fr, f.getName(), 0, null);
      } catch (FileNotFoundException e) {
        MinecraftScriptMod.getLogger().severe("Could not find " + f.getName());
      } catch (IOException e) {
        MinecraftScriptMod.getLogger().severe(e.toString());
      } catch (Error e) {
        MinecraftScriptMod.getLogger().severe("Error Loading " + f.getName());
      }
    }

    exitContext();
  }