Exemplo n.º 1
0
    public void compileMSA(List<Script> scripts, MCPlayer player) {

      for (FileInfo fi : msa) {
        List<Script> tempScripts;
        try {
          tempScripts =
              MethodScriptCompiler.preprocess(
                  MethodScriptCompiler.lex(fi.contents, fi.file, false));
          for (Script s : tempScripts) {
            try {
              try {
                s.compile();
                s.checkAmbiguous((ArrayList<Script>) scripts);
                scripts.add(s);
              } catch (ConfigCompileException e) {
                ConfigRuntimeException.React(
                    e,
                    "Compile error in script. Compilation will attempt to continue, however.",
                    player);
              }
            } catch (RuntimeException ee) {
              throw new RuntimeException(
                  "While processing a script, "
                      + "("
                      + fi.file()
                      + ") an unexpected exception occurred. (No further information"
                      + " is available, unfortunately.)",
                  ee);
            }
          }
        } catch (ConfigCompileException e) {
          ConfigRuntimeException.React(
              e, "Could not compile file " + fi.file + " compilation will halt.", player);
          return;
        }
      }
      int errors = 0;
      for (Script s : scripts) {
        if (s.compilerError) {
          errors++;
        }
      }
      if (errors > 0) {
        System.out.println(
            TermColors.YELLOW
                + "[CommandHelper]: "
                + (scripts.size() - errors)
                + " alias(es) defined, "
                + TermColors.RED
                + "with "
                + errors
                + " aliases with compile errors."
                + TermColors.reset());
        if (player != null) {
          player.sendMessage(
              MCChatColor.YELLOW
                  + "[CommandHelper]: "
                  + (scripts.size() - errors)
                  + " alias(es) defined, "
                  + MCChatColor.RED
                  + "with "
                  + errors
                  + " aliases with compile errors.");
        }
      } else {
        System.out.println(
            TermColors.YELLOW
                + "[CommandHelper]: "
                + scripts.size()
                + " alias(es) defined."
                + TermColors.reset());
        if (player != null) {
          player.sendMessage(
              MCChatColor.YELLOW + "[CommandHelper]: " + scripts.size() + " alias(es) defined.");
        }
      }
    }