public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { Help(p); return; } string[] args = message.SplitSpaces(); if (!Formatter.ValidFilename(p, args[0])) { return; } string language = args.Length > 1 ? args[1] : ""; ICompiler compiler = ICompiler.Lookup(language, p); if (compiler == null) { return; } // either "source" or "source1,source2,source3" string[] paths = args[0].SplitComma(); string dstPath = IScripting.CommandPath(paths[0]); for (int i = 0; i < paths.Length; i++) { paths[i] = compiler.CommandPath(paths[i]); } ScriptingOperations.Compile(p, compiler, "Command", paths, dstPath); }
static void CheckDirectory(string root, string directory, string type) { string path = Path.Combine(root, directory); string[] files = Directory.GetFiles(path, "*.cs"); foreach (string file in files) { WriteColored(ConsoleColor.Yellow, "Compiling " + file); var results = ScriptingOperations.Compile(log_player, cs_compiler, type, new[] { file }, null); compiled++; if (results == null || results.Errors.Count > 0) { failed++; } } }
static void CreatePlugin(Player p, string name, string language) { ICompiler engine = ScriptingOperations.GetCompiler(p, language); if (engine == null) { return; } string path = engine.PluginPath(name); p.Message("Creating a plugin example source"); string creator = p.IsSuper ? Server.Config.Name : p.truename; string source = engine.GenExamplePlugin(name, creator); File.WriteAllText(path, source); }
static void CompilePlugin(Player p, string name, string language) { ICompiler compiler = ICompiler.Lookup(language, p); if (compiler == null) { return; } // either "source" or "source1,source2,source3" string[] paths = name.SplitComma(); string dstPath = IScripting.PluginPath(paths[0]); for (int i = 0; i < paths.Length; i++) { paths[i] = compiler.PluginPath(paths[i]); } ScriptingOperations.Compile(p, compiler, "Plugin", paths, dstPath); }
Assembly CompileCommands(string path) { ICompiler compiler = GetCompiler(path); if (compiler == null) { Popup.Warning("Unsupported file '" + path + "'"); return(null); } ConsoleHelpPlayer p = new ConsoleHelpPlayer(); CompilerResults result = ScriptingOperations.Compile(p, compiler, "Command", new[] { path }, null); if (result != null) { return(result.CompiledAssembly); } Popup.Error(Colors.StripUsed(p.Messages)); return(null); }
public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { Help(p); return; } string[] args = message.SplitSpaces(); if (!Formatter.ValidFilename(p, args[0])) { return; } string language = args.Length > 1 ? args[1] : ""; ICompiler engine = ScriptingOperations.GetCompiler(p, language); if (engine == null) { return; } string path = engine.CommandPath(args[0]); if (File.Exists(path)) { p.Message("File {0} already exists. Choose another name.", path); return; } try { string source = engine.GenExampleCommand(args[0]); File.WriteAllText(path, source); } catch (Exception ex) { Logger.LogError("Error saving new command to " + path, ex); p.Message("An error occurred creating the command."); return; } p.Message("Successfully created a new command class."); }