Skip to content

[BUG] BasicIO still uses Console.KeyAvailable #2873

@Zwyxer

Description

@Zwyxer

Prerequisites

  • I made sure I am running the latest development build
  • I tried to look for similar issues before opening a new one
  • I have set debugmessages=true in config to diagnose my issue
  • 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

Metadata

Metadata

Assignees

Labels

a:bugCrash or feature not working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions