@@ -84,6 +84,17 @@ public void open(Player player) {
8484 player .sendMessage (messages .setupOpen ());
8585 }
8686
87+ private void reopenMenu (Player player , MenuState state ) {
88+ if (player == null || state == null ) {
89+ return ;
90+ }
91+ state .inventory = Bukkit .createInventory (player , INVENTORY_SIZE , messages .menu ().inventoryTitle ());
92+ openMenus .put (player .getUniqueId (), state );
93+ redraw (state );
94+ player .openInventory (state .inventory );
95+ player .sendMessage (messages .setupOpen ());
96+ }
97+
8798 @ EventHandler
8899 public void onInventoryClick (InventoryClickEvent event ) {
89100 if (!(event .getWhoClicked () instanceof Player player )) {
@@ -157,7 +168,9 @@ public void onInventoryClose(InventoryCloseEvent event) {
157168 }
158169 if (state .inventory != null && state .inventory .equals (event .getInventory ())) {
159170 openMenus .remove (player .getUniqueId ());
160- pendingInputs .remove (player .getUniqueId ());
171+ // Do NOT remove pendingInputs here. When the player starts a chat-based input
172+ // we close the inventory to let them type; removing pendingInputs on close
173+ // would cancel the pending chat entry and make typing impossible.
161174 }
162175 }
163176
@@ -207,6 +220,8 @@ private void startQuantityInput(Player player, MenuState state) {
207220 }
208221 pendingInputs .put (player .getUniqueId (), new PendingChatInput (state , InputType .QUANTITY ));
209222 player .sendMessage (messages .setupQuantityChatPrompt ());
223+ // Close inventory so the player can open chat and type the quantity
224+ player .closeInventory ();
210225 }
211226
212227 private void startPriceInput (Player player , MenuState state ) {
@@ -215,6 +230,8 @@ private void startPriceInput(Player player, MenuState state) {
215230 }
216231 pendingInputs .put (player .getUniqueId (), new PendingChatInput (state , InputType .PRICE ));
217232 player .sendMessage (messages .setupPriceChatPrompt ());
233+ // Close inventory so the player can open chat and type the price
234+ player .closeInventory ();
218235 }
219236
220237 private void handleChatInput (Player player , String message ) {
@@ -246,6 +263,7 @@ private void handleChatInput(Player player, String message) {
246263 }
247264 if (applyQuantityInput (player , pending .state , value )) {
248265 pendingInputs .remove (playerId );
266+ reopenMenu (player , pending .state );
249267 } else {
250268 player .sendMessage (messages .setupQuantityChatPrompt ());
251269 }
@@ -266,6 +284,7 @@ private void handleChatInput(Player player, String message) {
266284 }
267285 if (applyPriceInput (player , pending .state , value )) {
268286 pendingInputs .remove (playerId );
287+ reopenMenu (player , pending .state );
269288 } else {
270289 player .sendMessage (messages .setupPriceChatPrompt ());
271290 }
0 commit comments