mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Handle non-interactive terminal environments gracefully
When MCC runs in non-interactive terminals (e.g. CI runners, IDE embedded shells, piped input), several Console APIs throw exceptions because there is no real console attached. Changes: - Program.cs: Wrap Console.KeyAvailable / Console.ReadKey in HandleFailure() with try-catch so MCC does not crash on startup failure in headless environments. - Chunk.cs: Wrap Console.BufferWidth / BufferHeight in try-catch with fallback values (120x50) to prevent exceptions when rendering chunk maps without a console buffer. - Map.cs: Same treatment for the map rendering path - use safe fallback values when Console.BufferWidth/Height are unavailable. - ReplayHandler.cs: Replace Array.Reverse() (returns void in newer .NET) with .AsEnumerable().Reverse() to fix compilation with .NET 10 SDK where the void return breaks the fluent chain. Made-with: Cursor
This commit is contained in:
parent
494be0930b
commit
ff1c570a78
4 changed files with 21 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
|
@ -768,8 +768,10 @@ namespace MinecraftClient
|
|||
if (!String.IsNullOrEmpty(errorMessage))
|
||||
{
|
||||
ConsoleIO.Reset();
|
||||
while (Console.KeyAvailable)
|
||||
Console.ReadKey(true);
|
||||
try {
|
||||
while (Console.KeyAvailable)
|
||||
Console.ReadKey(true);
|
||||
} catch { }
|
||||
ConsoleIO.WriteLine(errorMessage);
|
||||
|
||||
if (disconnectReason.HasValue)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue