Exemplo n.º 1
0
 @Override
 public void reload() {
   MinecraftScriptMod.getLogger().fine("Reloading Scripting Scope");
   loadScope(false);
   loadAllScripts(_scriptsDirectory, false);
   loadAllScripts(new File(DimensionManager.getCurrentSaveRootDirectory(), "scripts"), true);
 }
Exemplo n.º 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();
  }