mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
[skip ci] Normalize all line endings
This commit is contained in:
parent
bdad4f302d
commit
37bcad37e0
11 changed files with 10827 additions and 10827 deletions
|
|
@ -1,55 +1,55 @@
|
|||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
public class Animation : Command
|
||||
{
|
||||
public override string CmdName { get { return "animation"; } }
|
||||
public override string CmdUsage { get { return "animation <mainhand|offhand>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_animation_desc; } }
|
||||
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
.Executes(r => GetUsage(r.Source, string.Empty))
|
||||
.Then(l => l.Literal("mainhand")
|
||||
.Executes(r => GetUsage(r.Source, "mainhand")))
|
||||
.Then(l => l.Literal("offhand")
|
||||
.Executes(r => GetUsage(r.Source, "offhand")))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoAnimation(r.Source, mainhand: true))
|
||||
.Then(l => l.Literal("mainhand")
|
||||
.Executes(r => DoAnimation(r.Source, mainhand: true)))
|
||||
.Then(l => l.Literal("offhand")
|
||||
.Executes(r => DoAnimation(r.Source, mainhand: false)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Executes(r => GetUsage(r.Source, string.Empty))
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
}
|
||||
|
||||
private int GetUsage(CmdResult r, string? cmd)
|
||||
{
|
||||
return r.SetAndReturn(cmd switch
|
||||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
"mainhand" => GetCmdDescTranslated(),
|
||||
"offhand" => GetCmdDescTranslated(),
|
||||
_ => GetCmdDescTranslated(),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
||||
private static int DoAnimation(CmdResult r, bool mainhand)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
return r.SetAndReturn(handler.DoAnimation(mainhand ? 1 : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
public class Animation : Command
|
||||
{
|
||||
public override string CmdName { get { return "animation"; } }
|
||||
public override string CmdUsage { get { return "animation <mainhand|offhand>"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_animation_desc; } }
|
||||
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
.Executes(r => GetUsage(r.Source, string.Empty))
|
||||
.Then(l => l.Literal("mainhand")
|
||||
.Executes(r => GetUsage(r.Source, "mainhand")))
|
||||
.Then(l => l.Literal("offhand")
|
||||
.Executes(r => GetUsage(r.Source, "offhand")))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoAnimation(r.Source, mainhand: true))
|
||||
.Then(l => l.Literal("mainhand")
|
||||
.Executes(r => DoAnimation(r.Source, mainhand: true)))
|
||||
.Then(l => l.Literal("offhand")
|
||||
.Executes(r => DoAnimation(r.Source, mainhand: false)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Executes(r => GetUsage(r.Source, string.Empty))
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
}
|
||||
|
||||
private int GetUsage(CmdResult r, string? cmd)
|
||||
{
|
||||
return r.SetAndReturn(cmd switch
|
||||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
"mainhand" => GetCmdDescTranslated(),
|
||||
"offhand" => GetCmdDescTranslated(),
|
||||
_ => GetCmdDescTranslated(),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
||||
private static int DoAnimation(CmdResult r, bool mainhand)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
return r.SetAndReturn(handler.DoAnimation(mainhand ? 1 : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,63 +1,63 @@
|
|||
using System.Linq;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
using MinecraftClient.Inventory;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
public class NameItem : Command
|
||||
{
|
||||
public override string CmdName => "nameitem";
|
||||
public override string CmdUsage => "nameitem <item name>";
|
||||
|
||||
public override string CmdDesc => Translations.cmd_nameitem_desc;
|
||||
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
.Executes(r => GetUsage(r.Source, string.Empty))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString())
|
||||
.Executes(r => DoSetItemName(r.Source, Arguments.GetString(r, "any"))))
|
||||
);
|
||||
}
|
||||
|
||||
private int GetUsage(CmdResult r, string? cmd)
|
||||
{
|
||||
return r.SetAndReturn(cmd switch
|
||||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
_ => GetCmdDescTranslated(),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
||||
private int DoSetItemName(CmdResult r, string itemName)
|
||||
{
|
||||
var handler = CmdResult.currentHandler!;
|
||||
|
||||
if (itemName.Trim().Length == 0)
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_nameitem_item_name_empty);
|
||||
|
||||
var currentInventory = handler.GetInventories().Count == 0
|
||||
? null
|
||||
: handler.GetInventories().Values.ToList().Last();
|
||||
|
||||
if (currentInventory is not { Type: ContainerType.Anvil })
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_nameitem_no_anvil_inventory_open);
|
||||
|
||||
if (currentInventory.Items[0].IsEmpty)
|
||||
return r.SetAndReturn(CmdResult.Status.Fail,
|
||||
Translations.cmd_nameitem_first_slot_empty);
|
||||
|
||||
return handler.SendRenameItem(itemName)
|
||||
? r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_nameitem_successful)
|
||||
: r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_nameitem_failed);
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
using MinecraftClient.Inventory;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
public class NameItem : Command
|
||||
{
|
||||
public override string CmdName => "nameitem";
|
||||
public override string CmdUsage => "nameitem <item name>";
|
||||
|
||||
public override string CmdDesc => Translations.cmd_nameitem_desc;
|
||||
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
.Executes(r => GetUsage(r.Source, string.Empty))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Then(l => l.Argument("any", Arguments.GreedyString())
|
||||
.Executes(r => DoSetItemName(r.Source, Arguments.GetString(r, "any"))))
|
||||
);
|
||||
}
|
||||
|
||||
private int GetUsage(CmdResult r, string? cmd)
|
||||
{
|
||||
return r.SetAndReturn(cmd switch
|
||||
{
|
||||
#pragma warning disable format // @formatter:off
|
||||
_ => GetCmdDescTranslated(),
|
||||
#pragma warning restore format // @formatter:on
|
||||
});
|
||||
}
|
||||
|
||||
private int DoSetItemName(CmdResult r, string itemName)
|
||||
{
|
||||
var handler = CmdResult.currentHandler!;
|
||||
|
||||
if (itemName.Trim().Length == 0)
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_nameitem_item_name_empty);
|
||||
|
||||
var currentInventory = handler.GetInventories().Count == 0
|
||||
? null
|
||||
: handler.GetInventories().Values.ToList().Last();
|
||||
|
||||
if (currentInventory is not { Type: ContainerType.Anvil })
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_nameitem_no_anvil_inventory_open);
|
||||
|
||||
if (currentInventory.Items[0].IsEmpty)
|
||||
return r.SetAndReturn(CmdResult.Status.Fail,
|
||||
Translations.cmd_nameitem_first_slot_empty);
|
||||
|
||||
return handler.SendRenameItem(itemName)
|
||||
? r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_nameitem_successful)
|
||||
: r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_nameitem_failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue