Changed getStock to only return the actual stock they have left instead of the total amount of items left (and protected it)

This commit is contained in:
auto committed 2023-01-22 22:04:46 +01:00
1 parent da5e514422
commit 55cb197b0b
2 files changed
+11 -3

No files matched your search

@@ -84,8 +84,16 @@ public class PlayerShop {
return playerShop;
}
/**
* @return total amount of purchases left until the shop can't sell/buy anymore
*/
public int getRemainingStock() {
return InventoryUtils.countItems(getInventory(), getItemStack());
int totalItems = InventoryUtils.countItems(getInventory(), getItemStack());
if (totalItems == 0)
return 0;
if (getAmount() == 0)
return 0;
return totalItems / getAmount();
}
public int getRemainingSpace() {