public void compileMS(MCPlayer player, Environment env) { for (FileInfo fi : ms) { boolean exception = false; try { env.getEnv(CommandHelperEnvironment.class) .SetCommandSender(Static.getServer().getConsole()); MethodScriptCompiler.registerAutoIncludes(env, null); MethodScriptCompiler.execute( MethodScriptCompiler.compile(MethodScriptCompiler.lex(fi.contents, fi.file, true)), env, null, null); } catch (ConfigCompileException e) { exception = true; ConfigRuntimeException.React( e, fi.file.getAbsolutePath() + " could not be compiled, due to a compile error.", player); } catch (ConfigRuntimeException e) { exception = true; ConfigRuntimeException.React(e, env); } catch (CancelCommandException e) { if (e.getMessage() != null && !"".equals(e.getMessage().trim())) { logger.log(Level.INFO, e.getMessage()); } } catch (ProgramFlowManipulationException e) { exception = true; ConfigRuntimeException.React( ConfigRuntimeException.CreateUncatchableException( "Cannot break program flow in main files.", e.getTarget()), env); } finally { env.getEnv(CommandHelperEnvironment.class).SetCommandSender(null); } if (exception) { if (Prefs.HaltOnFailure()) { logger.log( Level.SEVERE, TermColors.RED + "[CommandHelper]: Compilation halted due to unrecoverable failure." + TermColors.reset()); return; } } } logger.log( Level.INFO, TermColors.YELLOW + "[CommandHelper]: MethodScript files processed" + TermColors.reset()); if (player != null) { player.sendMessage(MCChatColor.YELLOW + "[CommandHelper]: MethodScript files processed"); } }
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."); } } }