2022-10-02 18:31:08 +08:00
|
|
|
|
using System.Collections.Generic;
|
2022-10-26 08:54:54 +08:00
|
|
|
|
using Brigadier.NET;
|
2020-05-01 08:28:22 -05:00
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Commands
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Sneak : Command
|
|
|
|
|
|
{
|
|
|
|
|
|
private bool sneaking = false;
|
2020-10-17 19:41:31 +08:00
|
|
|
|
public override string CmdName { get { return "Sneak"; } }
|
|
|
|
|
|
public override string CmdUsage { get { return "Sneak"; } }
|
2022-10-28 11:13:20 +08:00
|
|
|
|
public override string CmdDesc { get { return Translations.cmd_sneak_desc; } }
|
2020-05-01 08:28:22 -05:00
|
|
|
|
|
2022-10-26 08:54:54 +08:00
|
|
|
|
public override void RegisterCommand(McClient handler, CommandDispatcher<CommandSource> dispatcher)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-02 18:31:08 +08:00
|
|
|
|
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
2020-05-01 08:28:22 -05:00
|
|
|
|
{
|
|
|
|
|
|
if (sneaking)
|
|
|
|
|
|
{
|
2020-06-20 15:18:34 +02:00
|
|
|
|
var result = handler.SendEntityAction(Protocol.EntityActionType.StopSneaking);
|
2020-05-23 21:20:33 +08:00
|
|
|
|
if (result)
|
|
|
|
|
|
sneaking = false;
|
2022-10-28 11:13:20 +08:00
|
|
|
|
return result ? Translations.cmd_sneak_off : Translations.general_fail;
|
2020-05-01 08:28:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2020-06-20 15:18:34 +02:00
|
|
|
|
var result = handler.SendEntityAction(Protocol.EntityActionType.StartSneaking);
|
2020-05-23 21:20:33 +08:00
|
|
|
|
if (result)
|
|
|
|
|
|
sneaking = true;
|
2022-10-28 11:13:20 +08:00
|
|
|
|
return result ? Translations.cmd_sneak_on : Translations.general_fail;
|
2020-05-01 08:28:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|