public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { Help(p); return; } string[] args = message.SplitSpaces(); if (!Formatter.CheckFilenameOnly(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]); } compiler.Compile(p, "Command", paths, dstPath); }
public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { Help(p); return; } string[] args = message.SplitSpaces(); string language = args.Length > 1 ? args[1] : ""; ICompiler engine = ICompiler.Lookup(language, p); 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."); }
void CreateCommand(ICompiler engine) { string cmdName = txtCmdName.Text.Trim(); if (cmdName.Length == 0) { Popup.Warning("Command must have a name"); return; } string path = engine.CommandPath(cmdName); if (File.Exists(path)) { Popup.Warning("Command already exists"); return; } try { string source = engine.GenExampleCommand(cmdName); File.WriteAllText(path, source); } catch (Exception ex) { Logger.LogError(ex); Popup.Error("Failed to generate command. Check error logs for more details."); return; } Popup.Message("Command Cmd" + cmdName + engine.FileExtension + " created."); }
void btnCreate_Click(object sender, EventArgs e) { string cmdName = txtCmdName.Text.Trim(); if (cmdName.Length == 0) { Popup.Warning("Command must have a name"); return; } ICompiler engine = radVB.Checked ? ICompiler.VB : ICompiler.CS; string path = engine.CommandPath(cmdName); if (File.Exists(path)) { Popup.Warning("Command already exists"); return; } try { string source = engine.GenExampleCommand(cmdName); File.WriteAllText(path, source); } catch (Exception ex) { Logger.LogError(ex); Popup.Error("Failed to generate command. Check error logs for more details."); return; } Popup.Message("Command Cmd" + cmdName + engine.Ext + " created."); }
public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { Help(p); return; } string[] args = message.SplitSpaces(); string language = args.Length > 1 ? args[1] : ""; ICompiler engine = ICompiler.Lookup(language, p); if (engine == null) { return; } string srcPath = engine.CommandPath(args[0]); string dstPath = IScripting.CommandPath(args[0]); if (!File.Exists(srcPath)) { p.Message("File &9{0} &Snot found.", srcPath); return; } CompilerResults results = engine.Compile(srcPath, dstPath); if (!results.Errors.HasErrors) { p.Message("Command compiled successfully."); } else { ICompiler.SummariseErrors(results, p); p.Message("&WCompilation error. See " + ICompiler.ErrorPath + " for more information."); } }