From e5b81fe42843b677862ad3a45562f868988c4f63 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Thu, 26 Mar 2026 02:35:50 +0800 Subject: [PATCH] feat: add support for unsupported container type in inventory TUI - Implemented a check in the Inventory command to log a warning and return a failure status if the container type is not PlayerInventory. - Added a new localized string for the warning message to inform users about unsupported container types. These changes improve user feedback and error handling in the inventory management system. --- MinecraftClient/Commands/Inventory.cs | 6 ++++++ .../Resources/Translations/Translations.Designer.cs | 9 +++++++++ MinecraftClient/Resources/Translations/Translations.resx | 3 +++ 3 files changed, 18 insertions(+) diff --git a/MinecraftClient/Commands/Inventory.cs b/MinecraftClient/Commands/Inventory.cs index eeeee3d0..5936afd0 100644 --- a/MinecraftClient/Commands/Inventory.cs +++ b/MinecraftClient/Commands/Inventory.cs @@ -435,6 +435,12 @@ namespace MinecraftClient.Commands return r.SetAndReturn(CmdResult.Status.Fail, msg); } + if (container.Type != ContainerType.PlayerInventory) + { + handler.Log.Warn(string.Format(Translations.cmd_inventory_tui_unsupported_container, inventoryId)); + return r.SetAndReturn(CmdResult.Status.Fail); + } + handler.Log.Info(string.Format(Translations.cmd_inventory_tui_opening, inventoryId)); bool success = InventoryTuiHost.Launch(handler, inventoryId); diff --git a/MinecraftClient/Resources/Translations/Translations.Designer.cs b/MinecraftClient/Resources/Translations/Translations.Designer.cs index 10fddca1..d20d36af 100644 --- a/MinecraftClient/Resources/Translations/Translations.Designer.cs +++ b/MinecraftClient/Resources/Translations/Translations.Designer.cs @@ -6332,6 +6332,15 @@ namespace MinecraftClient { } } + /// + /// Looks up a localized string similar to TUI viewer does not support this container type (Inventory #{0}). Use '/inventory {0} list' to view its contents.. + /// + internal static string cmd_inventory_tui_unsupported_container { + get { + return ResourceManager.GetString("cmd.inventory.tui_unsupported_container", resourceCulture); + } + } + /// /// Looks up a localized string similar to Hold Shift + Left-click to select and copy text.. /// diff --git a/MinecraftClient/Resources/Translations/Translations.resx b/MinecraftClient/Resources/Translations/Translations.resx index a877ef80..5eb2fa76 100644 --- a/MinecraftClient/Resources/Translations/Translations.resx +++ b/MinecraftClient/Resources/Translations/Translations.resx @@ -2229,6 +2229,9 @@ Logging in... Failed to launch TUI inventory viewer. + + TUI viewer does not support this container type (Inventory #{0}). Use '/inventory {0} list' to view its contents. + Hold Shift + Left-click to select and copy text.