Minecraft-Console-Client icon indicating copy to clipboard operation
Minecraft-Console-Client copied to clipboard

[BUG] BasicIO still uses Console.KeyAvailable

Open Zwyxer opened this issue 7 months ago • 2 comments

Prerequisites

  • [x] I made sure I am running the latest development build
  • [x] I tried to look for similar issues before opening a new one
  • [x] I have set debugmessages=true in config to diagnose my issue
  • [x] I have redacted session tokens and passwords before attaching screenshots

Minecraft Version

1.16.5

Console Client Version

Latest

Expected Behavior

BasicIO mode should never throw MCC] Unhandled exception. System.InvalidOperationException: Cannot see if a key has been pressed when either application does not have a console or when console input has been redirected from a file. Try Console.In.Peek.

Actual Behavior

BasicIO is supposed to set to interative mode, yet subprocess breaks. Following is the offending line

public static void HandleFailure(string? errorMessage = null, bool versionError = false, ChatBots.AutoRelog.DisconnectReason? disconnectReason = null)
        {
            if (!String.IsNullOrEmpty(errorMessage))
            {
                ConsoleIO.Reset();
HERE>>>>
                while (Console.KeyAvailable)
                    Console.ReadKey(true);
                ConsoleIO.WriteLine(errorMessage);

HandleFailure is called in multiple places but doesn't check for BasicIO.

Steps to Reproduce the bug

  1. Run MCC Client using python subprocess
  2. Reach any situation which calls HandleFailure (eg single dash arguments or server offline)
  3. Code tries to use Console.KeyAvailable and gives error

Attach screenshot here (If applicable)

No response

Anythings that could help diagnosing the bug


Device

None

Operating System

None

Server Address (If applicable)

No response

Zwyxer avatar Jun 04 '25 13:06 Zwyxer

@breadbyte

milutinke avatar Jun 05 '25 17:06 milutinke

Ah, I thought I got all the code paths that used raw console input instead of deferring to the ConsoleIO helper. I'll take a look at it

breadbyte avatar Jun 05 '25 17:06 breadbyte