diff --git a/MinecraftClient/Commands/ExecMulti.cs b/MinecraftClient/Commands/ExecMulti.cs new file mode 100644 index 00000000..dc303c8a --- /dev/null +++ b/MinecraftClient/Commands/ExecMulti.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace MinecraftClient.Commands +{ + class ExecMulti : Command + { + public override string CmdName { get { return "execmulti"; } } + public override string CmdUsage { get { return "execmulti -> -> -> ..."; } } + public override string CmdDesc { get { return "cmd.execmulti.desc"; } } + + public override string Run(McClient handler, string command, Dictionary localVars) + { + if (hasArg(command)) + { + string commandsString = getArg(command); + IEnumerable commands = commandsString.Split("->") + .ToList() + .ConvertAll(command => command.Trim()) + .FindAll(command => !string.IsNullOrEmpty(command) || command.StartsWith("execmulti", StringComparison.OrdinalIgnoreCase)); + + foreach (string cmd in commands) + { + string output = ""; + handler.PerformInternalCommand(cmd, ref output); + + string log = Translations.TryGet( + "cmd.execmulti.executed", cmd, + string.IsNullOrEmpty(output) ? Translations.TryGet("cmd.execmulti.no_result") : Translations.TryGet("cmd.execmulti.result", output)); + + if (output.Contains("unknown command", StringComparison.OrdinalIgnoreCase)) + handler.Log.Error(log); + else handler.Log.Info(log); + } + + return ""; + } + + return GetCmdDescTranslated(); + } + } +} diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index 1d0cc4ad..403363ce 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -271,6 +271,12 @@ cmd.entityCmd.distance=Distance cmd.entityCmd.location=Location cmd.entityCmd.type=Type +# Exec Multi +cmd.execmulti.desc=Execute multiple commands one after another +cmd.execmulti.executed=Executed the command '{0}' with {1} +cmd.execmulti.result=result '{0}'! +cmd.execmulti.no_result=no result! + # Exit cmd.exit.desc=disconnect from the server.