Fix all for unlimited buying shop

Former-commit-id: d67875e7759e3e36001d855c1b1a197b7f8da6d4 [formerly db3d7eac8c2c76354b6c23448192b4fd19b2f29a]
Former-commit-id: b67f8991b1bb40dcf8c2e6540a0b21239a489821
This commit is contained in:
Ghost_chu committed 2019-11-15 20:58:42 +08:00
1 parent 51e95608b9
commit 21df3b3d57
1 file changed
+7
@@ -416,7 +416,14 @@ public class ShopManager {
amount = Integer.parseInt(message);
} catch (NumberFormatException e) {
if (message.equalsIgnoreCase(plugin.getConfig().getString("shop.word-for-trade-all-items", "all"))) {
if(!shop.isUnlimited()){
int invHaveItems = Util.countItems(p.getInventory(), shop.getItem());
int shopHaveSpaces = Util.countSpace(((ContainerShop) shop).getInventory(), shop.getItem());
amount = Math.min(shopHaveSpaces, invHaveItems);
}else{
amount = Util.countItems(p.getInventory(), shop.getItem());
}
} else {
p.sendMessage(MsgUtil.getMessage("shop-purchase-cancelled", p));
Util.debugLog("Receive the chat " + message + " and it format failed: " + e.getMessage());