mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Implement command completion suggestions.
This commit is contained in:
parent
5d2589b10f
commit
84cf749344
115 changed files with 4684 additions and 2695 deletions
|
|
@ -0,0 +1,36 @@
|
|||
using System.Text;
|
||||
using Brigadier.NET;
|
||||
|
||||
namespace MinecraftClient.CommandHandler.Patch
|
||||
{
|
||||
public static class CommandDispatcherExtensions
|
||||
{
|
||||
/**
|
||||
* This method unregisteres a previously declared command
|
||||
*
|
||||
* @param The name of the command to remove
|
||||
*/
|
||||
public static void Unregister(this CommandDispatcher<CmdResult> commandDispatcher, string commandname)
|
||||
{
|
||||
commandDispatcher.GetRoot().RemoveChild(commandname);
|
||||
}
|
||||
|
||||
public static string GetAllUsageString(this CommandDispatcher<CmdResult> commandDispatcher, string commandName, bool restricted)
|
||||
{
|
||||
char cmdChar = Settings.Config.Main.Advanced.InternalCmdChar.ToChar();
|
||||
string[] usages = commandDispatcher.GetAllUsage(commandDispatcher.GetRoot().GetChild(commandName), new(), restricted);
|
||||
StringBuilder sb = new();
|
||||
sb.AppendLine("All Usages:");
|
||||
foreach (var usage in usages)
|
||||
{
|
||||
sb.Append(cmdChar).Append(commandName).Append(' ');
|
||||
if (usage.Length > 0 && usage[0] == '_')
|
||||
sb.AppendLine(usage.Replace("_help -> ", $"_help -> {cmdChar}help "));
|
||||
else
|
||||
sb.AppendLine(usage);
|
||||
}
|
||||
sb.Remove(sb.Length - 1, 1);
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue