mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Implement console chat visibility controls
Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/159bd460-7950-4afe-9e69-4892220665e1 Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
This commit is contained in:
parent
9c994de2ee
commit
7bf342baab
14 changed files with 226 additions and 2 deletions
45
MinecraftClient/Commands/ClearConsole.cs
Normal file
45
MinecraftClient/Commands/ClearConsole.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
public class ClearConsole : Command
|
||||
{
|
||||
public override string CmdName => "clear-console";
|
||||
public override string CmdUsage => "clear-console";
|
||||
public override string CmdDesc => Translations.cmd_clear_console_desc;
|
||||
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
.Executes(r => GetUsage(r.Source))
|
||||
)
|
||||
);
|
||||
|
||||
var clearConsole = dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => Execute(r.Source))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Executes(r => GetUsage(r.Source))
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal("cc")
|
||||
.Executes(r => Execute(r.Source))
|
||||
.Redirect(clearConsole)
|
||||
);
|
||||
}
|
||||
|
||||
private int GetUsage(CmdResult result)
|
||||
{
|
||||
return result.SetAndReturn(GetCmdDescTranslated());
|
||||
}
|
||||
|
||||
private int Execute(CmdResult result)
|
||||
{
|
||||
ConsoleIO.ClearConsole();
|
||||
return result.SetAndReturn(CmdResult.Status.Done);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
MinecraftClient/Commands/ConsoleChat.cs
Normal file
49
MinecraftClient/Commands/ConsoleChat.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
public class ConsoleChat : Command
|
||||
{
|
||||
public override string CmdName => "console-chat";
|
||||
public override string CmdUsage => "console-chat [on|off]";
|
||||
public override string CmdDesc => Translations.cmd_console_chat_desc;
|
||||
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
.Executes(r => GetUsage(r.Source))
|
||||
)
|
||||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => SetChatVisibility(r.Source, null))
|
||||
.Then(l => l.Literal("on")
|
||||
.Executes(r => SetChatVisibility(r.Source, true)))
|
||||
.Then(l => l.Literal("off")
|
||||
.Executes(r => SetChatVisibility(r.Source, false)))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Executes(r => GetUsage(r.Source))
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
}
|
||||
|
||||
private int GetUsage(CmdResult result)
|
||||
{
|
||||
return result.SetAndReturn(GetCmdDescTranslated());
|
||||
}
|
||||
|
||||
private int SetChatVisibility(CmdResult result, bool? visible)
|
||||
{
|
||||
ConsoleIO.ChatVisible = visible ?? !ConsoleIO.ChatVisible;
|
||||
|
||||
return result.SetAndReturn(
|
||||
CmdResult.Status.Done,
|
||||
ConsoleIO.ChatVisible
|
||||
? Translations.cmd_console_chat_state_on
|
||||
: Translations.cmd_console_chat_state_off);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue