mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Add FileInputBot for non-interactive debugging and fix NbtToString crash
FileInputBot (ChatBots/FileInputBot.cs): - New ChatBot that monitors a text file (default: mcc_input.txt) for commands, enabling MCC control from Cursor Shell or any non-interactive environment where stdin is not available - Activated by setting MCC_FILE_INPUT env var (e.g. MCC_FILE_INPUT=1) - Polls every ~500ms for new lines appended to the file - Lines starting with "/" are sent as server chat/commands - Other lines are executed as MCC internal commands (same as console input) - File path overridable via MCC_INPUT_FILE env var McClient.cs: - Load FileInputBot when MCC_FILE_INPUT environment variable is set ChatParser.cs - NbtToString: - Fix InvalidCastException when NBT "text" or nameless root tag values are Int32 instead of String (happens with 1.20.6 SystemChat packets containing numeric values in the chat component tree) - Replace direct (string) casts with ?.ToString() ?? string.Empty Made-with: Cursor
This commit is contained in:
parent
8eac21b4a4
commit
967f67190c
3 changed files with 110 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
@ -510,8 +510,7 @@ namespace MinecraftClient.Protocol.Message
|
|||
{
|
||||
if (nbt.Count == 1 && nbt.TryGetValue("", out object? rootMessage))
|
||||
{
|
||||
// Nameless root tag
|
||||
return (string)rootMessage;
|
||||
return rootMessage?.ToString() ?? string.Empty;
|
||||
}
|
||||
|
||||
string message = string.Empty;
|
||||
|
|
@ -526,7 +525,7 @@ namespace MinecraftClient.Protocol.Message
|
|||
{
|
||||
case "text":
|
||||
{
|
||||
message = (string)value;
|
||||
message = value?.ToString() ?? string.Empty;
|
||||
}
|
||||
break;
|
||||
case "extra":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue