2022-10-26 08:54:54 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Brigadier.NET;
|
|
|
|
|
|
using Brigadier.NET.Builder;
|
2020-05-26 14:02:09 +05:00
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Commands
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Animation : Command
|
|
|
|
|
|
{
|
2020-10-17 19:41:31 +08:00
|
|
|
|
public override string CmdName { get { return "animation"; } }
|
|
|
|
|
|
public override string CmdUsage { get { return "animation <mainhand|offhand>"; } }
|
2022-10-28 11:13:20 +08:00
|
|
|
|
public override string CmdDesc { get { return Translations.cmd_animation_desc; } }
|
2020-05-26 14:02:09 +05:00
|
|
|
|
|
2022-10-26 08:54:54 +08:00
|
|
|
|
public override void RegisterCommand(McClient handler, CommandDispatcher<CommandSource> dispatcher)
|
|
|
|
|
|
{
|
|
|
|
|
|
dispatcher.Register(l =>
|
|
|
|
|
|
l.Literal("help").Then(l =>
|
|
|
|
|
|
l.Literal(CmdName).Executes(c => {
|
|
|
|
|
|
LogUsage(handler.Log);
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
})
|
|
|
|
|
|
)
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
dispatcher.Register(l =>
|
|
|
|
|
|
l.Literal(CmdName).Then(l =>
|
|
|
|
|
|
l.Literal("mainhand")
|
|
|
|
|
|
.Executes(c => {
|
|
|
|
|
|
return LogExecuteResult(handler.Log, handler.DoAnimation(0));
|
|
|
|
|
|
})
|
|
|
|
|
|
)
|
|
|
|
|
|
);
|
|
|
|
|
|
dispatcher.Register(l =>
|
|
|
|
|
|
l.Literal(CmdName).Then(l =>
|
|
|
|
|
|
l.Literal("0")
|
|
|
|
|
|
.Redirect(dispatcher.GetRoot().GetChild(CmdName).GetChild("mainhand"))
|
|
|
|
|
|
)
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
dispatcher.Register(l =>
|
|
|
|
|
|
l.Literal(CmdName).Then(l =>
|
|
|
|
|
|
l.Literal("offhand")
|
|
|
|
|
|
.Executes(c => {
|
|
|
|
|
|
return LogExecuteResult(handler.Log, handler.DoAnimation(1));
|
|
|
|
|
|
})
|
|
|
|
|
|
)
|
|
|
|
|
|
);
|
|
|
|
|
|
dispatcher.Register(l =>
|
|
|
|
|
|
l.Literal(CmdName).Then(l =>
|
|
|
|
|
|
l.Literal("1")
|
|
|
|
|
|
.Redirect(dispatcher.GetRoot().GetChild(CmdName).GetChild("offhand"))
|
|
|
|
|
|
)
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-02 18:31:08 +08:00
|
|
|
|
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
2020-05-26 14:02:09 +05:00
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
if (HasArg(command))
|
2020-05-26 14:02:09 +05:00
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
string[] args = GetArgs(command);
|
2020-05-26 14:02:09 +05:00
|
|
|
|
if (args.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (args[0] == "mainhand" || args[0] == "0")
|
|
|
|
|
|
{
|
|
|
|
|
|
handler.DoAnimation(0);
|
2022-10-28 11:13:20 +08:00
|
|
|
|
return Translations.general_done;
|
2020-05-26 14:02:09 +05:00
|
|
|
|
}
|
|
|
|
|
|
else if (args[0] == "offhand" || args[0] == "1")
|
|
|
|
|
|
{
|
|
|
|
|
|
handler.DoAnimation(1);
|
2022-10-28 11:13:20 +08:00
|
|
|
|
return Translations.general_done;
|
2020-05-26 14:02:09 +05:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return GetCmdDescTranslated();
|
2020-05-26 14:02:09 +05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return GetCmdDescTranslated();
|
2020-05-26 14:02:09 +05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-10-17 19:41:31 +08:00
|
|
|
|
else return GetCmdDescTranslated();
|
2020-05-26 14:02:09 +05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|