mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Implement command completion suggestions.
This commit is contained in:
parent
5d2589b10f
commit
84cf749344
115 changed files with 4684 additions and 2695 deletions
33
MinecraftClient/Commands/Help.cs
Normal file
33
MinecraftClient/Commands/Help.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
internal class Help : Command
|
||||
{
|
||||
public override string CmdName => throw new NotImplementedException();
|
||||
public override string CmdDesc => throw new NotImplementedException();
|
||||
public override string CmdUsage => throw new NotImplementedException();
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l =>
|
||||
l.Literal("help")
|
||||
.Executes(r => LogHelp(r.Source, handler, dispatcher))
|
||||
);
|
||||
}
|
||||
|
||||
private int LogHelp(CmdResult r, McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
var usage = dispatcher.GetSmartUsage(dispatcher.GetRoot(), CmdResult.Empty);
|
||||
StringBuilder sb = new();
|
||||
foreach (var item in usage)
|
||||
sb.AppendLine(Settings.Config.Main.Advanced.InternalCmdChar.ToChar() + item.Value);
|
||||
handler.Log.Info(string.Format(Translations.icmd_list, sb.ToString(), Settings.Config.Main.Advanced.InternalCmdChar.ToChar()));
|
||||
return r.SetAndReturn(CmdResult.Status.Done);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue