mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Added a way to execute multiple commands with a single command
This commit is contained in:
parent
223c13561c
commit
59cc4cea7c
2 changed files with 49 additions and 0 deletions
43
MinecraftClient/Commands/ExecMulti.cs
Normal file
43
MinecraftClient/Commands/ExecMulti.cs
Normal file
|
|
@ -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 <command 1> -> <command2> -> <command 3> -> ..."; } }
|
||||||
|
public override string CmdDesc { get { return "cmd.execmulti.desc"; } }
|
||||||
|
|
||||||
|
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||||
|
{
|
||||||
|
if (hasArg(command))
|
||||||
|
{
|
||||||
|
string commandsString = getArg(command);
|
||||||
|
IEnumerable<string> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -271,6 +271,12 @@ cmd.entityCmd.distance=Distance
|
||||||
cmd.entityCmd.location=Location
|
cmd.entityCmd.location=Location
|
||||||
cmd.entityCmd.type=Type
|
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
|
# Exit
|
||||||
cmd.exit.desc=disconnect from the server.
|
cmd.exit.desc=disconnect from the server.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue