Skip to content

Commit 502ec2f

Browse files
authored
Merge pull request #22 from ez-plugins/@fix/chat-amount-selection
Fix selecting playershop amounts in chat
2 parents 7a9fa8d + d59e2f2 commit 502ec2f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.skyblockexp</groupId>
77
<artifactId>ezshops</artifactId>
8-
<version>2.1.2</version>
8+
<version>2.1.3</version>
99
<name>EzShops Plugin</name>
1010
<description>Standalone plugin providing the Skyblock shop command and sign shops.</description>
1111
<packaging>jar</packaging>

src/main/java/com/skyblockexp/ezshops/playershop/PlayerShopSetupMenu.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)